winlin

refine log

... ... @@ -78,7 +78,7 @@ start() {
fi
# check again after start server
sleep 0.5
sleep 1
for ((i = 0; i < 5; i++)); do
# sleep a little while, for srs may start then crash.
sleep 0.1
... ...
... ... @@ -243,9 +243,8 @@ void SrsFastLog::write_log(char *str_log, int size, int _level)
printf("\033[31m%s\033[0m", str_log);
}
// if specified log file, write log to it.
if (!_srs_config->get_srs_log_file().empty()) {
if (fd < 0) {
// open log file.
if (!_srs_config->get_srs_log_file().empty() && fd < 0) {
std::string filename = _srs_config->get_srs_log_file();
fd = ::open(filename.c_str(), O_RDWR | O_APPEND);
... ... @@ -257,9 +256,8 @@ void SrsFastLog::write_log(char *str_log, int size, int _level)
);
}
}
// write log to file.
if (fd > 0) {
::write(fd, str_log, size);
}
}
}
... ...