mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine log
This commit is contained in:
parent
d9104f3b5e
commit
b290a00de7
2 changed files with 16 additions and 18 deletions
|
@ -78,7 +78,7 @@ start() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check again after start server
|
# check again after start server
|
||||||
sleep 0.5
|
sleep 1
|
||||||
for ((i = 0; i < 5; i++)); do
|
for ((i = 0; i < 5; i++)); do
|
||||||
# sleep a little while, for srs may start then crash.
|
# sleep a little while, for srs may start then crash.
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
|
|
|
@ -243,23 +243,21 @@ void SrsFastLog::write_log(char *str_log, int size, int _level)
|
||||||
printf("\033[31m%s\033[0m", str_log);
|
printf("\033[31m%s\033[0m", str_log);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if specified log file, write log to it.
|
// open log file.
|
||||||
if (!_srs_config->get_srs_log_file().empty()) {
|
if (!_srs_config->get_srs_log_file().empty() && fd < 0) {
|
||||||
if (fd < 0) {
|
std::string filename = _srs_config->get_srs_log_file();
|
||||||
std::string filename = _srs_config->get_srs_log_file();
|
|
||||||
|
fd = ::open(filename.c_str(), O_RDWR | O_APPEND);
|
||||||
fd = ::open(filename.c_str(), O_RDWR | O_APPEND);
|
|
||||||
|
if(fd == -1 && errno == ENOENT) {
|
||||||
if(fd == -1 && errno == ENOENT) {
|
fd = open(filename.c_str(),
|
||||||
fd = open(filename.c_str(),
|
O_RDWR | O_CREAT | O_TRUNC,
|
||||||
O_RDWR | O_CREAT | O_TRUNC,
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
|
||||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fd > 0) {
|
|
||||||
::write(fd, str_log, size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// write log to file.
|
||||||
|
if (fd > 0) {
|
||||||
|
::write(fd, str_log, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue