/* Write one line into specify log file, which instance is file_instanse. Append a LOG_LINE_SEPARATOR after log context to separate logs */
int write_log_line(const int file_instanse, const char *buf, const bool keep_open)
/* Write one line into specify log file, which instance is file_instanse. Append a LOG_LINE_SEPARATOR after log context to separate logs */
int write_log_line(const int file_instanse, const char *buf, const bool keep_open)
{
    int rtn = -EINVAL;
    if (file_instanse >= 0 && buf != NULL) {
        int rc = -1;
        rtn = aos_write(file_instanse, buf, strlen(buf));
        if (rtn > 0) {
            rc = aos_write(file_instanse, LOG_LINE_END_STR, 1);
            if (1 == rc) {
                rtn++;
            } else {
                rtn = rc;
            }
            aos_sync(file_instanse);
        } else {
            SESSION_FS_INFO("write fail rc %d\n", rtn);
        }
        if (!keep_open) {
            aos_close(file_instanse);
        }
    }
    return rtn;
}