]> arthur.barton.de Git - netatalk.git/blob - libatalk/util/test/logger_test.c
cd00dbf9fb2b4148dee10db8f1e578089c66e5c9
[netatalk.git] / libatalk / util / test / logger_test.c
1 #include <stdio.h>
2
3 #include <atalk/boolean.h>
4 #include <atalk/logger.h>
5
6 int main(int argc, char *argv[])
7 {
8   set_processname("logger_Test");
9 #if 0
10   LOG(log_severe, logtype_logger, "Logging Test starting: this should only log to syslog");
11
12   /* syslog testing */
13   LOG(log_severe, logtype_logger, "Disabling syslog logging.");
14   unsetuplog("Default");
15   LOG(log_error, logtype_default, "This shouldn't log to syslog: LOG(log_error, logtype_default).");
16   LOG(log_error, logtype_logger, "This shouldn't log to syslog: LOG(log_error, logtype_logger).");
17   setuplog("Default LOG_INFO");
18   LOG(log_info, logtype_logger, "Set syslog logging to 'log_info', so this should log again. LOG(log_info, logtype_logger).");
19   LOG(log_error, logtype_logger, "This should log to syslog: LOG(log_error, logtype_logger).");
20   LOG(log_error, logtype_default, "This should log to syslog. LOG(log_error, logtype_default).");
21   LOG(log_debug, logtype_logger, "This shouldn't log to syslog. LOG(log_debug, logtype_logger).");
22   LOG(log_debug, logtype_default, "This shouldn't log to syslog. LOG(log_debug, logtype_default).");
23   LOG(log_severe, logtype_logger, "Disabling syslog logging.");
24   unsetuplog("Default");
25 #endif
26   /* filelog testing */
27
28   setuplog("DSI log_maxdebug test.log");
29   LOG(log_info, logtype_dsi, "This should log.");
30   LOG(log_error, logtype_default, "This should not log.");
31
32   setuplog("Default log_debug test.log");
33   LOG(log_debug, logtype_default, "This should log.");
34   LOG(log_maxdebug, logtype_default, "This should not log.");
35
36   LOG(log_maxdebug, logtype_dsi, "This should still log.");
37
38   /* flooding prevention check */
39   LOG(log_debug, logtype_default, "Flooding 12x1");
40   for (int i = 0; i < 12; i++) {
41       LOG(log_error, logtype_default, "flooding 12x1 1");
42   }
43
44   LOG(log_debug, logtype_default, "=============");
45   LOG(log_debug, logtype_default, "Flooding 12x3");
46   for (int i = 0; i < 12; i++) {
47       LOG(log_error, logtype_default, "flooding 12x3 1");
48       LOG(log_error, logtype_default, "flooding 12x3 2");
49       LOG(log_error, logtype_default, "flooding 12x3 3");
50   }
51
52   LOG(log_debug, logtype_default, "=============");
53   LOG(log_debug, logtype_default, "Flooding 12x4");
54   for (int i = 0; i < 12; i++) {
55       LOG(log_error, logtype_default, "flooding 12x4 1");
56       LOG(log_error, logtype_default, "flooding 12x4 2");
57       LOG(log_error, logtype_default, "flooding 12x4 3");
58       LOG(log_error, logtype_default, "flooding 12x4 4");
59   }
60
61   LOG(log_debug, logtype_default, "=============");
62   LOG(log_debug, logtype_default, "Flooding 12x5");
63   for (int i = 0; i < 12; i++) {
64       LOG(log_error, logtype_default, "flooding 12x5 1");
65       LOG(log_error, logtype_default, "flooding 12x5 2");
66       LOG(log_error, logtype_default, "flooding 12x5 3");
67       LOG(log_error, logtype_default, "flooding 12x5 4");
68       LOG(log_error, logtype_default, "flooding 12x5 5");
69   }
70
71   return 0;
72 }
73
74