32 lines
615 B
C
32 lines
615 B
C
|
|
||
|
#include "log.h"
|
||
|
#include <stdarg.h>
|
||
|
|
||
|
#if REMOVE_PATH_FROM_FILE
|
||
|
const char *remove_path(const char *path) {
|
||
|
char *p = strrchr(path, DIR_SEPERATOR);
|
||
|
if (NULL != p && *(p) != '\0') {
|
||
|
return (p + 1);
|
||
|
}
|
||
|
return path;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
int log_write(server* UNUSED_PARAM(srv), connection* UNUSED_PARAM(con), const char *fmt, ...) {
|
||
|
va_list ap;
|
||
|
GString *logline;
|
||
|
|
||
|
logline = g_string_sized_new(0);
|
||
|
va_start(ap, fmt);
|
||
|
g_string_vprintf(logline, fmt, ap);
|
||
|
va_end(ap);
|
||
|
|
||
|
|
||
|
g_string_append_len(logline, CONST_STR_LEN("\r\n"));
|
||
|
write(STDERR_FILENO, logline->str, logline->len);
|
||
|
g_string_free(logline, TRUE);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|