Nilorea Library
C utilities for networking, threading, graphics
ex_log.c

Nilorea Library log api test.

Nilorea Library log api test

Author
Castagnier Mickael
Version
1.0
Date
24/10/2018
#include "nilorea/n_log.h"
int main( void )
{
puts( "LOG_NULL" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "EMERG" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "ALERT" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "CRIT" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "ERR" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "WARNING" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "NOTICE" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "INFO" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
puts( "DEBUG" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
set_log_file( "ex_log.log" );
n_log( LOG_EMERG, "EMERG" );
n_log( LOG_ALERT, "ALERT" );
n_log( LOG_CRIT, "CRIT" );
n_log( LOG_ERR, "ERR" );
n_log( LOG_WARNING, "WARNING" );
n_log( LOG_NOTICE, "NOTICE" );
n_log( LOG_INFO, "INFO" );
n_log( LOG_DEBUG, "DEBUG" );
n_nodup_log( LOG_INFO, "Duplicated test" );
n_nodup_log( LOG_INFO, "Duplicated test" );
n_nodup_log( LOG_INFO, "Duplicated test" );
n_nodup_log_indexed( LOG_INFO, "NODUPINDEX1", "Duplicated test 2" );
n_nodup_log_indexed( LOG_INFO, "NODUPINDEX1", "Duplicated test 2" );
n_nodup_log_indexed( LOG_INFO, "NODUPINDEX2", "Duplicated test 3" );
n_nodup_log_indexed( LOG_INFO, "NODUPINDEX2", "Duplicated test 3" );
dump_nodup_log( "log_nodup.log" );
TS_LOG *SAFELOG = NULL ;
open_safe_logging( &SAFELOG, "ex_log_safe.log", "w" );
write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
close_safe_logging( SAFELOG );
Free( SAFELOG );
exit( 0 );
}
#define Free(__ptr)
Free Handler to get errors.
Definition: n_common.h:256
#define LOG_ALERT
action must be taken immediately
Definition: n_log.h:54
int write_safe_log(TS_LOG *log, char *pat,...)
write to a thread-safe logging file
Definition: n_log.c:337
int open_safe_logging(TS_LOG **log, char *pathname, char *opt)
Open a thread-safe logging file.
Definition: n_log.c:298
#define LOG_EMERG
system is unusable
Definition: n_log.h:52
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
Definition: n_log.h:74
#define LOG_DEBUG
debug-level messages
Definition: n_log.h:66
#define LOG_ERR
error conditions
Definition: n_log.h:58
#define LOG_CRIT
critical conditions
Definition: n_log.h:56
int close_safe_logging(TS_LOG *log)
close a thread-safe logging file
Definition: n_log.c:368
int set_log_file(char *file)
Set the logging to a file instead of stderr.
Definition: n_log.c:135
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
Definition: n_log.c:97
#define LOG_NOTICE
normal but significant condition
Definition: n_log.h:62
#define LOG_WARNING
warning conditions
Definition: n_log.h:60
#define LOG_NULL
no log output
Definition: n_log.h:27
#define LOG_INFO
informational
Definition: n_log.h:64
ThreadSafe LOGging structure.
Definition: n_log.h:83
#define n_nodup_log(__LEVEL__,...)
nodup log macro helper
Definition: n_nodup_log.h:34
int dump_nodup_log(char *file)
Dump the duplicate error log hash table in a file.
Definition: n_nodup_log.c:350
int close_nodup_log()
Empty nodup logtable and close the no duplicate logging session.
Definition: n_nodup_log.c:79
#define n_nodup_log_indexed(__LEVEL__, __PREF__,...)
nodup log indexed macro helper
Definition: n_nodup_log.h:41
int init_nodup_log(int max)
initialize the no duplicate logging system
Definition: n_nodup_log.c:36
Generic log system.
Generic No Dup Log system.