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