![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Generic logging system. More...
#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include <pthread.h>#include <string.h>#include <inttypes.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <syslog.h>
Include dependency graph for n_log.c:Go to the source code of this file.
Data Structures | |
| struct | LOG_LEVELS |
| internal struct to handle log types More... | |
Macros | |
| #define | COLOR_BLUE "\033[34m" |
| #define | COLOR_CYAN "\033[36m" |
| #define | COLOR_GREEN "\033[32m" |
| #define | COLOR_MAGENTA "\033[35m" |
| #define | COLOR_RED "\033[31m" |
| #define | COLOR_RESET "\033[0m" |
| #define | COLOR_WHITE "\033[37m" |
| #define | COLOR_YELLOW "\033[33m" |
Functions | |
| void | _n_log (int level, const char *file, const char *func, int line, const char *format,...) |
| Logging function. | |
| int | _vscprintf_so (const char *format, va_list pargs) |
| compute the size of a string made with format 'fmt' and arguments in the va_list 'ap', helper for vasprintf | |
| int | asprintf (char *strp[], const char *fmt,...) |
| snprintf from a va_list | |
| int | close_safe_logging (TS_LOG *log) |
| close a thread-safe logging file | |
| void | close_sysjrnl (void) |
| Close syslog connection or clean internals for event log. | |
| FILE * | get_log_file (void) |
| return the current log_file | |
| int | get_log_level (void) |
| Get the global log level value. | |
| int | open_safe_logging (TS_LOG **log, char *pathname, char *opt) |
| Open a thread-safe logging file. | |
| char * | open_sysjrnl (char *identity) |
| Open connection to syslog or create internals for event log. | |
| int | set_log_file (char *file) |
| Set the logging to a file instead of stderr. | |
| void | set_log_level (const int log_level) |
| Set the global log level value ( static int LOG_LEVEL ) | |
| int | vasprintf (char **strp, const char *fmt, va_list ap) |
| snprintf from a va_list, helper for asprintf | |
| int | write_safe_log (TS_LOG *log, char *pat,...) |
| write to a thread-safe logging file | |
Variables | |
| static FILE * | log_file = NULL |
| static FILE handling if logging to file is enabled | |
| static int | LOG_LEVEL = -1 |
| static global maximum wanted log level value | |
| static int | LOG_TYPE = -4 |
| static global logging type ( STDERR, FILE, SYSJRNL ) | |
| static LOG_LEVELS | prioritynames [] |
| array of log levels | |
| char * | proc_name = NULL |
| static proc name, for windows event log | |
| static int | terminal_support_colors = 0 |
| struct LOG_LEVELS |
| int _vscprintf_so | ( | const char * | format, |
| va_list | pargs | ||
| ) |
compute the size of a string made with format 'fmt' and arguments in the va_list 'ap', helper for vasprintf
| format | format to pass to printf |
| pargs | va_list to use as printf parameter |
Definition at line 185 of file n_log.c.
Referenced by vasprintf().
Here is the caller graph for this function:| int asprintf | ( | char * | strp[], |
| const char * | fmt, | ||
| ... | |||
| ) |
snprintf from a va_list
| strp | string holding the result |
| fmt | format to pass to printf |
| ... | list of format parameters |
Definition at line 227 of file n_log.c.
References vasprintf().
Here is the call graph for this function:| int vasprintf | ( | char ** | strp, |
| const char * | fmt, | ||
| va_list | ap | ||
| ) |
snprintf from a va_list, helper for asprintf
| strp | string holding the result |
| fmt | format to pass to printf |
| ap | va_list to use as printf parameter |
Definition at line 203 of file n_log.c.
References _vscprintf_so(), and Malloc.
Referenced by _n_log(), _n_nodup_log(), _n_nodup_log_indexed(), and asprintf().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
static FILE handling if logging to file is enabled
Definition at line 67 of file n_log.c.
Referenced by _n_log(), get_log_file(), main(), and set_log_file().
|
static |
static global maximum wanted log level value
Definition at line 61 of file n_log.c.
Referenced by get_log_level(), and set_log_level().
|
static |
static global logging type ( STDERR, FILE, SYSJRNL )
Definition at line 64 of file n_log.c.
Referenced by _n_log(), and set_log_level().
|
static |
array of log levels
Definition at line 48 of file n_log.c.
Referenced by _n_log().
| char* proc_name = NULL |
static proc name, for windows event log
Definition at line 70 of file n_log.c.
Referenced by _n_log(), close_sysjrnl(), and open_sysjrnl().
|
static |
Definition at line 25 of file n_log.c.
Referenced by _n_log(), and set_log_level().