Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_log.c
Go to the documentation of this file.
1
9#include "nilorea/n_log.h"
10#include "nilorea/n_nodup_log.h"
11
12int main(void) {
13 puts("LOG_NULL");
15 n_log(LOG_EMERG, "EMERG");
16 n_log(LOG_ALERT, "ALERT");
17 n_log(LOG_CRIT, "CRIT");
18 n_log(LOG_ERR, "ERR");
19 n_log(LOG_WARNING, "WARNING");
20 n_log(LOG_NOTICE, "NOTICE");
21 n_log(LOG_INFO, "INFO");
22 n_log(LOG_DEBUG, "DEBUG");
23 puts("EMERG");
25 n_log(LOG_EMERG, "EMERG");
26 n_log(LOG_ALERT, "ALERT");
27 n_log(LOG_CRIT, "CRIT");
28 n_log(LOG_ERR, "ERR");
29 n_log(LOG_WARNING, "WARNING");
30 n_log(LOG_NOTICE, "NOTICE");
31 n_log(LOG_INFO, "INFO");
32 n_log(LOG_DEBUG, "DEBUG");
33 puts("ALERT");
35 n_log(LOG_EMERG, "EMERG");
36 n_log(LOG_ALERT, "ALERT");
37 n_log(LOG_CRIT, "CRIT");
38 n_log(LOG_ERR, "ERR");
39 n_log(LOG_WARNING, "WARNING");
40 n_log(LOG_NOTICE, "NOTICE");
41 n_log(LOG_INFO, "INFO");
42 n_log(LOG_DEBUG, "DEBUG");
43 puts("CRIT");
45 n_log(LOG_EMERG, "EMERG");
46 n_log(LOG_ALERT, "ALERT");
47 n_log(LOG_CRIT, "CRIT");
48 n_log(LOG_ERR, "ERR");
49 n_log(LOG_WARNING, "WARNING");
50 n_log(LOG_NOTICE, "NOTICE");
51 n_log(LOG_INFO, "INFO");
52 n_log(LOG_DEBUG, "DEBUG");
53 puts("ERR");
55 n_log(LOG_EMERG, "EMERG");
56 n_log(LOG_ALERT, "ALERT");
57 n_log(LOG_CRIT, "CRIT");
58 n_log(LOG_ERR, "ERR");
59 n_log(LOG_WARNING, "WARNING");
60 n_log(LOG_NOTICE, "NOTICE");
61 n_log(LOG_INFO, "INFO");
62 n_log(LOG_DEBUG, "DEBUG");
63 puts("WARNING");
65 n_log(LOG_EMERG, "EMERG");
66 n_log(LOG_ALERT, "ALERT");
67 n_log(LOG_CRIT, "CRIT");
68 n_log(LOG_ERR, "ERR");
69 n_log(LOG_WARNING, "WARNING");
70 n_log(LOG_NOTICE, "NOTICE");
71 n_log(LOG_INFO, "INFO");
72 n_log(LOG_DEBUG, "DEBUG");
73 puts("NOTICE");
75 n_log(LOG_EMERG, "EMERG");
76 n_log(LOG_ALERT, "ALERT");
77 n_log(LOG_CRIT, "CRIT");
78 n_log(LOG_ERR, "ERR");
79 n_log(LOG_WARNING, "WARNING");
80 n_log(LOG_NOTICE, "NOTICE");
81 n_log(LOG_INFO, "INFO");
82 n_log(LOG_DEBUG, "DEBUG");
83 puts("INFO");
85 n_log(LOG_EMERG, "EMERG");
86 n_log(LOG_ALERT, "ALERT");
87 n_log(LOG_CRIT, "CRIT");
88 n_log(LOG_ERR, "ERR");
89 n_log(LOG_WARNING, "WARNING");
90 n_log(LOG_NOTICE, "NOTICE");
91 n_log(LOG_INFO, "INFO");
92 n_log(LOG_DEBUG, "DEBUG");
93 puts("DEBUG");
95 n_log(LOG_EMERG, "EMERG");
96 n_log(LOG_ALERT, "ALERT");
97 n_log(LOG_CRIT, "CRIT");
98 n_log(LOG_ERR, "ERR");
99 n_log(LOG_WARNING, "WARNING");
100 n_log(LOG_NOTICE, "NOTICE");
101 n_log(LOG_INFO, "INFO");
102 n_log(LOG_DEBUG, "DEBUG");
103 set_log_file("ex_log.log");
104 n_log(LOG_EMERG, "EMERG");
105 n_log(LOG_ALERT, "ALERT");
106 n_log(LOG_CRIT, "CRIT");
107 n_log(LOG_ERR, "ERR");
108 n_log(LOG_WARNING, "WARNING");
109 n_log(LOG_NOTICE, "NOTICE");
110 n_log(LOG_INFO, "INFO");
111 n_log(LOG_DEBUG, "DEBUG");
112
114
115 n_nodup_log(LOG_INFO, "Duplicated test");
116 n_nodup_log(LOG_INFO, "Duplicated test");
117 n_nodup_log(LOG_INFO, "Duplicated test");
118 n_nodup_log_indexed(LOG_INFO, "NODUPINDEX1", "Duplicated test 2");
119 n_nodup_log_indexed(LOG_INFO, "NODUPINDEX1", "Duplicated test 2");
120 n_nodup_log_indexed(LOG_INFO, "NODUPINDEX2", "Duplicated test 3");
121 n_nodup_log_indexed(LOG_INFO, "NODUPINDEX2", "Duplicated test 3");
122
123 dump_nodup_log("log_nodup.log");
124
126
127 TS_LOG* SAFELOG = NULL;
128 open_safe_logging(&SAFELOG, "ex_log_safe.log", "w");
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 write_safe_log(SAFELOG, "%s(%d): %s", __FILE__, __LINE__, __func__);
134
135 close_safe_logging(SAFELOG);
136 Free(SAFELOG);
137
138 exit(0);
139}
int main(void)
#define Free(__ptr)
Free Handler to get errors.
Definition n_common.h:240
#define LOG_ALERT
action must be taken immediately
Definition n_log.h:53
int write_safe_log(TS_LOG *log, char *pat,...)
write to a thread-safe logging file
Definition n_log.c:404
int open_safe_logging(TS_LOG **log, char *pathname, char *opt)
Open a thread-safe logging file.
Definition n_log.c:338
#define LOG_EMERG
system is unusable
Definition n_log.h:51
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
Definition n_log.h:70
#define LOG_DEBUG
debug-level messages
Definition n_log.h:65
#define LOG_ERR
error conditions
Definition n_log.h:57
#define LOG_CRIT
critical conditions
Definition n_log.h:55
int close_safe_logging(TS_LOG *log)
close a thread-safe logging file
Definition n_log.c:432
int set_log_file(char *file)
Set the logging to a file instead of stderr.
Definition n_log.c:151
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
Definition n_log.c:104
#define LOG_NOTICE
normal but significant condition
Definition n_log.h:61
#define LOG_WARNING
warning conditions
Definition n_log.h:59
#define LOG_NULL
no log output
Definition n_log.h:27
#define LOG_INFO
informational
Definition n_log.h:63
ThreadSafe LOGging structure.
Definition n_log.h:76
#define n_nodup_log(__LEVEL__,...)
nodup log macro helper
Definition n_nodup_log.h:34
int init_nodup_log(size_t max)
initialize the no duplicate logging system
Definition n_nodup_log.c:36
int dump_nodup_log(char *file)
Dump the duplicate error log hash table in a file The table is first written to a temporary file whic...
int close_nodup_log()
Empty nodup logtable and close the no duplicate logging session.
Definition n_nodup_log.c:69
#define n_nodup_log_indexed(__LEVEL__, __PREF__,...)
nodup log indexed macro helper
Definition n_nodup_log.h:40
Generic log system.
Generic No Dup Log system.