Nilorea Library
C utilities for networking, threading, graphics
ex_log.c
1
7#include "nilorea/n_log.h"
9
10int main( void )
11{
12 puts( "LOG_NULL" );
14 n_log( LOG_EMERG, "EMERG" );
15 n_log( LOG_ALERT, "ALERT" );
16 n_log( LOG_CRIT, "CRIT" );
17 n_log( LOG_ERR, "ERR" );
18 n_log( LOG_WARNING, "WARNING" );
19 n_log( LOG_NOTICE, "NOTICE" );
20 n_log( LOG_INFO, "INFO" );
21 n_log( LOG_DEBUG, "DEBUG" );
22 puts( "EMERG" );
24 n_log( LOG_EMERG, "EMERG" );
25 n_log( LOG_ALERT, "ALERT" );
26 n_log( LOG_CRIT, "CRIT" );
27 n_log( LOG_ERR, "ERR" );
28 n_log( LOG_WARNING, "WARNING" );
29 n_log( LOG_NOTICE, "NOTICE" );
30 n_log( LOG_INFO, "INFO" );
31 n_log( LOG_DEBUG, "DEBUG" );
32 puts( "ALERT" );
34 n_log( LOG_EMERG, "EMERG" );
35 n_log( LOG_ALERT, "ALERT" );
36 n_log( LOG_CRIT, "CRIT" );
37 n_log( LOG_ERR, "ERR" );
38 n_log( LOG_WARNING, "WARNING" );
39 n_log( LOG_NOTICE, "NOTICE" );
40 n_log( LOG_INFO, "INFO" );
41 n_log( LOG_DEBUG, "DEBUG" );
42 puts( "CRIT" );
44 n_log( LOG_EMERG, "EMERG" );
45 n_log( LOG_ALERT, "ALERT" );
46 n_log( LOG_CRIT, "CRIT" );
47 n_log( LOG_ERR, "ERR" );
48 n_log( LOG_WARNING, "WARNING" );
49 n_log( LOG_NOTICE, "NOTICE" );
50 n_log( LOG_INFO, "INFO" );
51 n_log( LOG_DEBUG, "DEBUG" );
52 puts( "ERR" );
54 n_log( LOG_EMERG, "EMERG" );
55 n_log( LOG_ALERT, "ALERT" );
56 n_log( LOG_CRIT, "CRIT" );
57 n_log( LOG_ERR, "ERR" );
58 n_log( LOG_WARNING, "WARNING" );
59 n_log( LOG_NOTICE, "NOTICE" );
60 n_log( LOG_INFO, "INFO" );
61 n_log( LOG_DEBUG, "DEBUG" );
62 puts( "WARNING" );
64 n_log( LOG_EMERG, "EMERG" );
65 n_log( LOG_ALERT, "ALERT" );
66 n_log( LOG_CRIT, "CRIT" );
67 n_log( LOG_ERR, "ERR" );
68 n_log( LOG_WARNING, "WARNING" );
69 n_log( LOG_NOTICE, "NOTICE" );
70 n_log( LOG_INFO, "INFO" );
71 n_log( LOG_DEBUG, "DEBUG" );
72 puts( "NOTICE" );
74 n_log( LOG_EMERG, "EMERG" );
75 n_log( LOG_ALERT, "ALERT" );
76 n_log( LOG_CRIT, "CRIT" );
77 n_log( LOG_ERR, "ERR" );
78 n_log( LOG_WARNING, "WARNING" );
79 n_log( LOG_NOTICE, "NOTICE" );
80 n_log( LOG_INFO, "INFO" );
81 n_log( LOG_DEBUG, "DEBUG" );
82 puts( "INFO" );
84 n_log( LOG_EMERG, "EMERG" );
85 n_log( LOG_ALERT, "ALERT" );
86 n_log( LOG_CRIT, "CRIT" );
87 n_log( LOG_ERR, "ERR" );
88 n_log( LOG_WARNING, "WARNING" );
89 n_log( LOG_NOTICE, "NOTICE" );
90 n_log( LOG_INFO, "INFO" );
91 n_log( LOG_DEBUG, "DEBUG" );
92 puts( "DEBUG" );
94 n_log( LOG_EMERG, "EMERG" );
95 n_log( LOG_ALERT, "ALERT" );
96 n_log( LOG_CRIT, "CRIT" );
97 n_log( LOG_ERR, "ERR" );
98 n_log( LOG_WARNING, "WARNING" );
99 n_log( LOG_NOTICE, "NOTICE" );
100 n_log( LOG_INFO, "INFO" );
101 n_log( LOG_DEBUG, "DEBUG" );
102 set_log_file( "ex_log.log" );
103 n_log( LOG_EMERG, "EMERG" );
104 n_log( LOG_ALERT, "ALERT" );
105 n_log( LOG_CRIT, "CRIT" );
106 n_log( LOG_ERR, "ERR" );
107 n_log( LOG_WARNING, "WARNING" );
108 n_log( LOG_NOTICE, "NOTICE" );
109 n_log( LOG_INFO, "INFO" );
110 n_log( LOG_DEBUG, "DEBUG" );
111
112 init_nodup_log( 0 );
113
114 n_nodup_log( LOG_INFO, "Duplicated test" );
115 n_nodup_log( LOG_INFO, "Duplicated test" );
116 n_nodup_log( LOG_INFO, "Duplicated test" );
117 n_nodup_log_indexed( LOG_INFO, "NODUPINDEX1", "Duplicated test 2" );
118 n_nodup_log_indexed( LOG_INFO, "NODUPINDEX1", "Duplicated test 2" );
119 n_nodup_log_indexed( LOG_INFO, "NODUPINDEX2", "Duplicated test 3" );
120 n_nodup_log_indexed( LOG_INFO, "NODUPINDEX2", "Duplicated test 3" );
121
122 dump_nodup_log( "log_nodup.log" );
123
125
126 TS_LOG *SAFELOG = NULL ;
127 open_safe_logging( &SAFELOG, "ex_log_safe.log", "w" );
128 write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
129 write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
130 write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
131 write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
132 write_safe_log( SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__ );
133
134 close_safe_logging( SAFELOG );
135 Free( SAFELOG );
136
137 exit( 0 );
138}
#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.