Compare commits
3 commits
ff2a2d977f
...
1f9050b69e
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f9050b69e | |||
| ecff681d37 | |||
| 9415b61953 |
2 changed files with 8 additions and 2 deletions
|
|
@ -364,17 +364,23 @@ void chroma_log(const char *level, const char *format, ...) {
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
char timestamp[32];
|
char timestamp[32];
|
||||||
|
int truncation_check = 0;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct tm *tm_info;
|
struct tm *tm_info;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
tm_info = localtime(&tv.tv_sec);
|
tm_info = localtime(&tv.tv_sec);
|
||||||
|
|
||||||
snprintf(timestamp, sizeof(timestamp), "%04d-%02d-%02d %02d:%02d:%02d.%03d",
|
truncation_check = snprintf(timestamp, sizeof(timestamp), "%04d-%02d-%02d %02d:%02d:%02d.%03d",
|
||||||
tm_info->tm_year + 1900, tm_info->tm_mon + 1, tm_info->tm_mday,
|
tm_info->tm_year + 1900, tm_info->tm_mon + 1, tm_info->tm_mday,
|
||||||
tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec,
|
tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec,
|
||||||
(int)(tv.tv_usec / 1000));
|
(int)(tv.tv_usec / 1000));
|
||||||
|
|
||||||
|
if(truncation_check > 32 || truncation_check < 0) {
|
||||||
|
// Something went seriously wrong with the snprintf, this is a fairly serious error as
|
||||||
|
// the timestamp may be incomplete or corrupted, so print a warning
|
||||||
|
printf("Following timestamp may be incomplete, truncated or corrupted!\n");
|
||||||
|
}
|
||||||
printf("[%s] %s: ", timestamp, level);
|
printf("[%s] %s: ", timestamp, level);
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,4 @@ ProtectHome=read-only
|
||||||
ReadWritePaths=%h/.config/chroma
|
ReadWritePaths=%h/.config/chroma
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-useer.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue