2 Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
17 #endif /* HAVE_CONFIG_H */
22 #include <atalk/logger.h>
24 int main(int argc, char *argv[])
26 set_processname("logger_Test");
28 LOG(log_severe, logtype_logger, "Logging Test starting: this should only log to syslog");
31 LOG(log_severe, logtype_logger, "Disabling syslog logging.");
32 unsetuplog("Default");
33 LOG(log_error, logtype_default, "This shouldn't log to syslog: LOG(log_error, logtype_default).");
34 LOG(log_error, logtype_logger, "This shouldn't log to syslog: LOG(log_error, logtype_logger).");
35 setuplog("Default LOG_INFO");
36 LOG(log_info, logtype_logger, "Set syslog logging to 'log_info', so this should log again. LOG(log_info, logtype_logger).");
37 LOG(log_error, logtype_logger, "This should log to syslog: LOG(log_error, logtype_logger).");
38 LOG(log_error, logtype_default, "This should log to syslog. LOG(log_error, logtype_default).");
39 LOG(log_debug, logtype_logger, "This shouldn't log to syslog. LOG(log_debug, logtype_logger).");
40 LOG(log_debug, logtype_default, "This shouldn't log to syslog. LOG(log_debug, logtype_default).");
41 LOG(log_severe, logtype_logger, "Disabling syslog logging.");
42 unsetuplog("Default");
46 setuplog("DSI:maxdebug", "test.log");
47 LOG(log_info, logtype_dsi, "This should log.");
48 LOG(log_error, logtype_default, "This should not log.");
50 setuplog("Default:debug", "test.log");
51 LOG(log_debug, logtype_default, "This should log.");
52 LOG(log_maxdebug, logtype_default, "This should not log.");
54 LOG(log_maxdebug, logtype_dsi, "This should still log.");
56 /* flooding prevention check */
57 LOG(log_debug, logtype_default, "Flooding 3x");
58 for (int i = 0; i < 3; i++) {
59 LOG(log_debug, logtype_default, "Flooding...");
62 LOG(log_debug, logtype_default, "1"); LOG(log_debug, logtype_default, "2"); LOG(log_debug, logtype_default, "3");
64 LOG(log_debug, logtype_default, "-============");
65 LOG(log_debug, logtype_default, "Flooding 5x");
66 for (int i = 0; i < 5; i++) {
67 LOG(log_debug, logtype_default, "Flooding...");
69 LOG(log_debug, logtype_default, "1"); LOG(log_debug, logtype_default, "2"); LOG(log_debug, logtype_default, "3");
71 LOG(log_debug, logtype_default, "o============");
72 LOG(log_debug, logtype_default, "Flooding 2005x");
73 for (int i = 0; i < 2005; i++) {
74 LOG(log_debug, logtype_default, "Flooding...");
76 LOG(log_debug, logtype_default, "1"); LOG(log_debug, logtype_default, "2"); LOG(log_debug, logtype_default, "3");
78 LOG(log_debug, logtype_default, "0============");
79 LOG(log_debug, logtype_default, "Flooding 11x1");
80 for (int i = 0; i < 11; i++) {
81 LOG(log_error, logtype_default, "flooding 11x1 1");
84 LOG(log_debug, logtype_default, "1============");
85 LOG(log_debug, logtype_default, "Flooding 11x2");
86 for (int i = 0; i < 11; i++) {
87 LOG(log_error, logtype_default, "flooding 11x2 1");
88 LOG(log_error, logtype_default, "flooding 11x2 2");
91 LOG(log_debug, logtype_default, "2============");
92 LOG(log_debug, logtype_default, "Flooding 11x3");
93 for (int i = 0; i < 11; i++) {
94 LOG(log_error, logtype_default, "flooding 11x3 1");
95 LOG(log_error, logtype_default, "flooding 11x3 2");
96 LOG(log_error, logtype_default, "flooding 11x3 3");
99 LOG(log_debug, logtype_default, "3============");
100 LOG(log_debug, logtype_default, "Flooding 11x4");
101 for (int i = 0; i < 11; i++) {
102 LOG(log_error, logtype_default, "flooding 11x4 1");
103 LOG(log_error, logtype_default, "flooding 11x4 2");
104 LOG(log_error, logtype_default, "flooding 11x4 3");
105 LOG(log_error, logtype_default, "flooding 11x4 4");