]> arthur.barton.de Git - netatalk.git/blob - libatalk/util/test/logger_test.c
fixes
[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 3x");
40   for (int i = 0; i < 3; i++) {
41       LOG(log_debug, logtype_default, "Flooding...");
42   }
43   LOG(log_debug, logtype_default, "1");
44   LOG(log_debug, logtype_default, "2");
45   LOG(log_debug, logtype_default, "3");
46
47   LOG(log_debug, logtype_default, "-============");
48   LOG(log_debug, logtype_default, "Flooding 5x");
49   for (int i = 0; i < 5; i++) {
50       LOG(log_debug, logtype_default, "Flooding...");
51   }
52   LOG(log_debug, logtype_default, "1");
53   LOG(log_debug, logtype_default, "2");
54   LOG(log_debug, logtype_default, "3");
55
56   LOG(log_debug, logtype_default, "0============");
57   LOG(log_debug, logtype_default, "Flooding 11x1");
58   for (int i = 0; i < 11; i++) {
59       LOG(log_error, logtype_default, "flooding 11x1 1");
60   }
61
62   LOG(log_debug, logtype_default, "1============");
63   LOG(log_debug, logtype_default, "Flooding 11x2");
64   for (int i = 0; i < 11; i++) {
65       LOG(log_error, logtype_default, "flooding 11x2 1");
66       LOG(log_error, logtype_default, "flooding 11x2 2");
67   }
68
69   LOG(log_debug, logtype_default, "2============");
70   LOG(log_debug, logtype_default, "Flooding 11x3");
71   for (int i = 0; i < 11; i++) {
72       LOG(log_error, logtype_default, "flooding 11x3 1");
73       LOG(log_error, logtype_default, "flooding 11x3 2");
74       LOG(log_error, logtype_default, "flooding 11x3 3");
75   }
76
77   LOG(log_debug, logtype_default, "3============");
78   LOG(log_debug, logtype_default, "Flooding 11x4");
79   for (int i = 0; i < 11; i++) {
80       LOG(log_error, logtype_default, "flooding 11x4 1");
81       LOG(log_error, logtype_default, "flooding 11x4 2");
82       LOG(log_error, logtype_default, "flooding 11x4 3");
83       LOG(log_error, logtype_default, "flooding 11x4 4");
84   }
85
86
87   return 0;
88 }
89
90