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:
parent
4f6f8a8244
commit
beae090d67
1 changed files with 7 additions and 7 deletions
|
@ -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 (dangerous) {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
nb_header = snprintf(buffer, size,
|
written = snprintf(buffer, size,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d][%d] ",
|
"[%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),
|
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);
|
level, tag, getpid(), cid, errno);
|
||||||
} else {
|
} else {
|
||||||
nb_header = snprintf(buffer, size,
|
written = snprintf(buffer, size,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d][%d] ",
|
"[%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),
|
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);
|
level, getpid(), cid, errno);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
nb_header = snprintf(buffer, size,
|
written = snprintf(buffer, size,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%s][%d][%d] ",
|
"[%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),
|
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);
|
level, tag, getpid(), cid);
|
||||||
} else {
|
} else {
|
||||||
nb_header = snprintf(buffer, size,
|
written = snprintf(buffer, size,
|
||||||
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%d] ",
|
"[%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),
|
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);
|
level, getpid(), cid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nb_header == -1) {
|
if (written == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the header size.
|
// write the header size.
|
||||||
*psize = srs_min(size - 1, nb_header);
|
*psize = written;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue