2 Unix SMB/CIFS implementation.
4 A test server that only does logging.
6 Copyright (C) Andrew Tridgell 1992-2005
7 Copyright (C) Martin Pool 2002
8 Copyright (C) Jelmer Vernooij 2002
9 Copyright (C) James J Myers 2003 <myersjj@samba.org>
10 Copyright (C) Douglas Bagnall 2022
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "lib/cmdline/cmdline.h"
29 #ifdef USING_CMDLINE_S3
30 #include "lib/util/debug_s3.h"
33 #define BINARY_NAME "test_s4_logging"
35 static int log_level
= 1;
38 #include "lib/util/debug-classes/debug-classname-table.c"
40 static int log_all_classes(int level
)
43 const char *name
= NULL
;
44 for (i
= 0; i
< ARRAY_SIZE(default_classname_table
); i
++) {
45 name
= default_classname_table
[i
];
47 ("logging for '%s' [%zu], at level %d\n",
51 * That's it for the tests *here*. The invoker of this
52 * process will have set up an smb.conf that directs the
53 * output in particular ways, and will be looking to see that
61 static int init_daemon(TALLOC_CTX
*mem_ctx
,
69 struct poptOption long_options
[] = {
74 .argInfo
= POPT_ARG_INT
,
76 .descrip
= "log at this level",
77 .argDescrip
= "LEVEL",
85 setproctitle(BINARY_NAME
);
87 ok
= samba_cmdline_init(mem_ctx
,
88 SAMBA_CMDLINE_CONFIG_SERVER
,
89 true /* require_smbconf */);
91 *error
= "Failed to init cmdline parser!\n";
95 pc
= samba_popt_get_context(BINARY_NAME
,
101 *error
= "Failed to setup popt context!\n";
102 return ENOTRECOVERABLE
;
105 while((opt
= poptGetNextOpt(pc
)) != -1) {
106 fprintf(stderr
, "\nInvalid option %s: %s\n\n",
107 poptBadOption(pc
, 0), poptStrerror(opt
));
108 poptPrintUsage(pc
, stderr
, 0);
114 #ifdef USING_CMDLINE_S3
121 int main(int argc
, const char *argv
[])
124 const char *error
= NULL
;
125 TALLOC_CTX
*mem_ctx
= talloc_stackframe();
126 if (mem_ctx
== NULL
) {
130 setproctitle_init(argc
, discard_const(argv
), environ
);
132 rc
= init_daemon(mem_ctx
, argc
, argv
, &error
);
134 fprintf(stderr
, "error [%d]: %s\n", rc
, error
);
135 exit_daemon(error
, rc
);
138 rc
= log_all_classes(log_level
);
140 fprintf(stderr
, "error in log_all_classes [%d]\n", rc
);
141 exit_daemon("logging error", rc
);
144 TALLOC_FREE(mem_ctx
);