/* Copies one line from file_instanse into buf, On sucessful the destination buf buf is changed into NULL terminated C String. If log content size is longer than buf_len-1, remain will be not saved and NULL terminatated is implicitly appended at the end of destination. */
int get_log_line(const int fd, char *buf, const uint16_t buf_len)
/* Copies one line from file_instanse into buf, On sucessful the destination buf buf is changed into NULL terminated C String. If log content size is longer than buf_len-1, remain will be not saved and NULL terminatated is implicitly appended at the end of destination. */
int get_log_line(const int fd, char *buf, const uint16_t buf_len)
{
    int rc = -1;
    int cnt = 0;
    if (fd < 0 || NULL == buf || buf_len <= 0) {
        return -1;
    }
    memset(buf, 0, buf_len);
    while ((cnt < buf_len) && (0 < aos_read(fd, &buf[cnt], 1))) {
        if (buf[cnt] == LOG_LINE_SEPARATOR) {
            break;
        }
        cnt++;
    }
    if (cnt == 0) {
        rc = 0;
    } else if (cnt < buf_len) {
        if (buf[cnt - 1] == LOG_LINE_SEPARATOR) {
            buf[cnt - 1] = 0;
        } else {
            buf[cnt] = 0;
        }
        rc = cnt;
    } else {
        rc = cnt;
        buf[cnt - 1] = 0;
    }
    return rc;
}