1 .\" Copyright (c) 2000 Kungliga Tekniska Högskolan
17 .Nd provides unified logging
19 .Fd #include <parse_units.h>
33 .Fo "Log_method *log_open"
38 .Fa "Log_method *method"
40 .Fo "Log_unit *log_unit_init"
41 .Fa "Log_method *method"
42 .Fa "const char *name"
43 .Fa "struct units *lognames"
44 .Fa "unsigned long default_mask"
46 .Fo "void log_unit_free"
47 .Fa "Log_method *method"
50 .Fo "void log_set_mask"
52 .Fa "unsigned long mask"
54 .Fo "unsigned log_get_mask"
57 .Fo "void log_mask2str"
58 .Fa "Log_method *method"
63 .Fo "void log_set_mask_str"
64 .Fa "Log_method *method"
65 .Fa "Log_unit *default_unit"
70 will let you have a unified logging system throu-out your whole project.
71 No more strange errnos like
73 returned from libraries since they can print to stderr (not knowing
74 what fd will be connected to fd number 2).
77 will open a Log_method that all Log_units will log though, Log_method
78 controls to what device the log is sent.
79 Logging devices, passed in fname, are syslog, /dev/stderr, or a file.
81 Options can be passes to the subsystem with an extra colon. Valid
83 .D1 syslog[:pid,no-delay,console,stderr[:facility]]
84 .D1 {/dev/stderr,/file}[:notime]
86 closeses the Log_method and assosiated Log_units.
89 will return a logging unit, that is used by a subsystem.
92 will free a logging unit allocated by
96 set the logging mask for a logging unit.
99 get the logging mask for a logging unit.
102 convert the longing mask for `unit' (or all if this is NULL), to a
103 string that can be printed.
104 The string can be parsed by
105 .Fn log_set_mask_str .
108 will set the mask for `default_unit' (or all if this is NULL).
111 #include <parse_units.h>
115 enum { A_WARNING = 1, A_DEBUG = 2 };
117 struct units u_units[] = {
118 { "debug", A_DEBUG },
119 { "warning", A_WARNING },
124 main (int argc, char **argv)
130 m = log_open ("log-tester", "/dev/stderr");
132 errx (1, "log_open");
134 u = log_unit_init (m, "test-foo", u_units, A_WARNING);
136 errx (1, "log_unit_init");
138 log_log (u, A_WARNING, "this should show");
139 log_log (u, A_DEBUG, "this should NOT show");
141 log_mask2str (m, NULL, buf, sizeof(buf));
142 printf ("logmask: %s\\n", buf);
150 Should maybe include a log_logx version.