Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
raf
d16a861e52 Merge pull request 'meta: fix the warning during compilation' (#7) from amr-patch-2 into main
Reviewed-on: #7
Reviewed-by: raf <raf@notashelf.dev>
2025-11-02 17:57:48 +00:00
amr
1f9050b69e fix: this solves the warning during compilation
This not only solves the warning/error brought up during compilation, it's also just a sort of belt'n'braces approach to make absolutely sure the timestamp length is correct and didn't get truncated or some other error. This was a new warning/error introduced back in gcc 7.1, and it's one of those "you *should* do it this way because it's technically the correct way" things that most developers roll their eyes at but, logically, they're technically correct.
2025-11-02 08:31:16 +00:00
raf
ecff681d37 Merge pull request 'Fix typo in systemd service' (#6) from amr-patch-1 into main
Reviewed-on: #6
Reviewed-by: raf <raf@notashelf.dev>
2025-11-02 08:07:21 +00:00

View file

@ -364,17 +364,23 @@ void chroma_log(const char *level, const char *format, ...) {
va_list args;
char timestamp[32];
int truncation_check = 0;
struct timeval tv;
struct tm *tm_info;
gettimeofday(&tv, NULL);
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_hour, tm_info->tm_min, tm_info->tm_sec,
(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);
va_start(args, format);