summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoikk2025-10-26 16:43:55 +0100
committerSoikk2025-10-26 16:43:55 +0100
commit009e1f2b15c8de452c5c245d99640859a458e86c (patch)
treebb1b3bd6ea27eebe46e79bfed23838631443de2c
parentb62b7ab69a5f68fc40633c2828ba0eea04bccda2 (diff)
downloadsoikk-libs-009e1f2b15c8de452c5c245d99640859a458e86c.tar.xz
soikk-libs-009e1f2b15c8de452c5c245d99640859a458e86c.tar.zst
Fixed logging bug and added padding to PID field
-rwxr-xr-xlog/log.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/log/log.c b/log/log.c
index 74db0eb..74ee010 100755
--- a/log/log.c
+++ b/log/log.c
@@ -149,7 +149,8 @@ void log_message(int level, char *file, int line, char *fmt, ...){
char msg[MSG_LIMIT] = {0};
int written = snprintf(msg, MSG_LIMIT-2,
#ifdef PID
- "[%d] "
+ // the maximum PID is a 5 digit number. this shoud be customizable
+ "[%-5d] "
#endif
"%s%s%s%s%s%s%s\t",
#ifdef PID
@@ -173,8 +174,10 @@ void log_message(int level, char *file, int line, char *fmt, ...){
msg[written] = '\n';
if(log_levels[level].stder) fputs(msg, stderr);
for(int i = 0; i < log_levels[level].nfps; i++){
- if(log_levels[level].fps[i] != NULL)
+ if(log_levels[level].fps[i] != NULL){
fputs(msg, log_levels[level].fps[i]);
+ fflush(log_levels[level].fps[i]);
+ }
}
}
}