aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2022-04-21 21:03:12 +0200
committerJeremias Stotter <jeremias@stotter.eu>2022-04-21 21:03:12 +0200
commit4277409f6bd1a8c9d2ba97dd162f717a80e72a04 (patch)
tree902e703cb2472b696d918c3c882bd3a21987710f
parent463fd7d47d56e6f9f4a0e08ac641c862b800a5b5 (diff)
downloadJBlog-4277409f6bd1a8c9d2ba97dd162f717a80e72a04.tar.gz
JBlog-4277409f6bd1a8c9d2ba97dd162f717a80e72a04.tar.bz2
JBlog-4277409f6bd1a8c9d2ba97dd162f717a80e72a04.zip
Changed the log function a bit
-rw-r--r--jblog.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/jblog.c b/jblog.c
index 847c42c..8db6aef 100644
--- a/jblog.c
+++ b/jblog.c
@@ -78,7 +78,6 @@ void jb_log(int loglevel, bool include_errno, char* error_string) {
int curr_errno = errno;
char error_full[4096] = {0};
char err_prefix[8] = {0};
- FILE* nologfile_out = stdout;
switch(loglevel) {
case LL_INFO:
strcpy(err_prefix, "INFO");
@@ -88,14 +87,12 @@ void jb_log(int loglevel, bool include_errno, char* error_string) {
break;
case LL_ERR:
strcpy(err_prefix, "ERROR");
- nologfile_out = stderr;
break;
}
snprintf(error_full, 4095, "(%ld) %s: %s%s%s\n", time(NULL), err_prefix,error_string, include_errno ? " : " : "", include_errno ? strerror(curr_errno) : "" );
- if(logfile >= 0) {
- (void)!write(logfile, error_full, strlen(error_full));
- }
- fprintf(nologfile_out, error_full);
+ (void)!write(logfile > 0 ? logfile :
+ (loglevel == LL_ERR ? 2 : 1),
+ error_full, strlen(error_full));
}
// Escape a html character
Jeremias Stotters git repositories generated by CGIT