1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine logger header

This commit is contained in:
winlin 2017-05-31 13:52:21 +08:00
parent 4f6f8a8244
commit beae090d67

View file

@ -225,39 +225,39 @@ bool srs_log_header(char* buffer, int size, bool utc, bool dangerous, const char
}
}
int nb_header = -1;
int written = -1;
if (dangerous) {
if (tag) {
nb_header = snprintf(buffer, size,
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d][%d] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
level, tag, getpid(), cid, errno);
} else {
nb_header = snprintf(buffer, size,
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d][%d] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
level, getpid(), cid, errno);
}
} else {
if (tag) {
nb_header = snprintf(buffer, size,
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
level, tag, getpid(), cid);
} else {
nb_header = snprintf(buffer, size,
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
level, getpid(), cid);
}
}
if (nb_header == -1) {
if (written == -1) {
return false;
}
// write the header size.
*psize = srs_min(size - 1, nb_header);
*psize = written;
return true;
}