Table of Contents
- LOGGING: logging to console, to file, to syslog, to event log
- Structures
- Functions
- Defines
- Functions Documentation
- function write_safe_log
- function set_log_level
- function set_log_file_fd
- function set_log_file
- function open_sysjrnl
- function open_safe_logging
- function get_log_level
- function get_log_file
- function close_sysjrnl
- function close_safe_logging
- function _n_log
- Macros Documentation
LOGGING: logging to console, to file, to syslog, to event log
Structures
| Name | |
|---|---|
| struct | TS_LOG ThreadSafe LOGging structure. |
Functions
| Name | |
|---|---|
| int | write_safe_log(TS_LOG * log, char * pat, ... ) write to a thread-safe logging file |
| void | set_log_level(const int log_level) Set global log level. |
| int | set_log_file_fd(FILE * fd) set an already open stream (stdout, stderr, a caller's FILE) as standard log output, never closed by the library |
| int | set_log_file(char * file) set a file as standard log output |
| char * | open_sysjrnl(const char * identity) Open a syslog / set name for event log. |
| int | open_safe_logging(TS_LOG ** log, char * pathname, char * opt) Open a thread-safe logging file. |
| int | get_log_level(void ) Return the global log level. |
| FILE * | get_log_file(void ) get the log file name if any |
| void | close_sysjrnl(void ) close syslog / free name for event log |
| int | close_safe_logging(TS_LOG * log) close a thread-safe logging file |
| void | _n_log(int level, const char * file, const char * func, int line, const char * format, ... ) Full log function. |
Defines
| Name | |
|---|---|
| n_log(LEVEL, ...) Logging function wrapper to get line and func. |
|
| N_PRINTF_FORMAT(fmt, args) declare a function printf-like; nothing on a compiler without attributes |
|
| LOG_WARNING warning conditions |
|
| LOG_SYSJRNL to sysjrnl |
|
| LOG_STDERR internal, default LOG_TYPE |
|
| LOG_NULL no log output |
|
| LOG_NOTICE normal but significant condition |
|
| LOG_INFO informational |
|
| LOG_FILE internal, logging to file |
|
| LOG_ERR error conditions |
|
| LOG_EMERG system is unusable |
|
| LOG_DEBUG debug-level messages |
|
| LOG_CRIT critical conditions |
|
| LOG_ALERT action must be taken immediately |
Functions Documentation
function write_safe_log
int write_safe_log(
TS_LOG * log,
char * pat,
...
)
write to a thread-safe logging file
Parameters:
- log A TS_LOG handler
- pat Pattern for writting (i.e "%d %d %s")
Return: TRUE on success, FALSE on error
function set_log_level
void set_log_level(
const int log_level
)
Set global log level.
Parameters:
- log_level Log level value. Supported: NOLOG,LOG_NOTICE/INFO/ERR/DEBUG,LOG_FILE/STDERR/SYSJRNL
Set the global log level value ( static int LOG_LEVEL ).
Possible values: NOLOG , NOTICE , VERBOSE , ERROR , DEBUG
Set global log level.
function set_log_file_fd
int set_log_file_fd(
FILE * fd
)
set an already open stream (stdout, stderr, a caller's FILE) as standard log output, never closed by the library
Parameters:
- fd The open stream to log to
Return: TRUE or FALSE
Set the logging to an already open stream instead of stderr.
set an already open stream (stdout, stderr, a caller's FILE) as standard log output, never closed by the library
The stream stays owned by the caller: the library never closes it, not here and not when a later set_log_file() / set_log_file_fd() replaces it. A log file previously opened by set_log_file() is closed first. Typical use is set_log_file_fd(stdout), e.g. under Emscripten where stderr shows up as console errors in the browser.
function set_log_file
int set_log_file(
char * file
)
set a file as standard log output
Parameters:
- file The filename where to log
Return: TRUE or FALSE
Set the logging to a file instead of stderr.
set a file as standard log output
function open_sysjrnl
char * open_sysjrnl(
const char * identity
)
Open a syslog / set name for event log.
Parameters:
- identity Tag for syslog or NULL to use argv[0]
Return: NULL or identity if success
Open connection to syslog or create internals for event log.
Open a syslog / set name for event log.
function open_safe_logging
int open_safe_logging(
TS_LOG ** log,
char * pathname,
char * opt
)
Open a thread-safe logging file.
Parameters:
- log A TS_LOG handler
- pathname The file path (if any) and name
- opt Options for opening (please never forget to use "w")
Return: TRUE on success , FALSE on error , -1000 if already open
function get_log_level
int get_log_level(
void
)
Return the global log level.
Return: static int LOG_LEVEL
Get the global log level value.
Possible values: NOLOG , NOTICE , VERBOSE , ERROR , DEBUG
Return the global log level.
function get_log_file
FILE * get_log_file(
void
)
get the log file name if any
Return: a valid FILE handle or NULL
return the current log_file
get the log file name if any
function close_sysjrnl
void close_sysjrnl(
void
)
close syslog / free name for event log
Close syslog connection or clean internals for event log.
close syslog / free name for event log
function close_safe_logging
int close_safe_logging(
TS_LOG * log
)
close a thread-safe logging file
Parameters:
- log A TS_LOG handler
Return: TRUE on success, FALSE on error
function _n_log
void _n_log(
int level,
const char * file,
const char * func,
int line,
const char * format,
...
)
Full log function.
Parameters:
- level Logging level
- file File containing the emitted log
- func Function emitting the log
- line Line of the log
- format Format and string of the log, printf style
Logging function.
Must be wrapped in a MACRO to get the correct file/func/line information
Full log function.
log( level , const char *format , ... ) is a macro around _log
Macros Documentation
define n_log
#define n_log(
__LEVEL__,
...
)
do { \
_n_log(__LEVEL__, __FILE__, __func__, __LINE__, __VA_ARGS__); \
} while (0)
Logging function wrapper to get line and func.
define N_PRINTF_FORMAT
#define N_PRINTF_FORMAT(
fmt,
args
)
declare a function printf-like; nothing on a compiler without attributes
define LOG_WARNING
#define LOG_WARNING 4
warning conditions
define LOG_SYSJRNL
#define LOG_SYSJRNL 100
to sysjrnl
define LOG_STDERR
#define LOG_STDERR -4
internal, default LOG_TYPE
define LOG_NULL
#define LOG_NULL -1
no log output
define LOG_NOTICE
#define LOG_NOTICE 5
normal but significant condition
define LOG_INFO
#define LOG_INFO 6
informational
define LOG_FILE
#define LOG_FILE -3
internal, logging to file
define LOG_ERR
#define LOG_ERR 3
error conditions
define LOG_EMERG
#define LOG_EMERG 0
system is unusable
define LOG_DEBUG
#define LOG_DEBUG 7
debug-level messages
define LOG_CRIT
#define LOG_CRIT 2
critical conditions
define LOG_ALERT
#define LOG_ALERT 1
action must be taken immediately
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB