Coda Distributed File System
ds_log.h
Go to the documentation of this file.
1#ifndef _DS_LOG_H_
2#define _DS_LOG_H_
3
4/* uses varargs */
5#include <stdarg.h>
6
7#include <odytypes.h>
8
9/*
10 * ds_log.h: public interface to the logging data structure
11 */
12
13/*
14 * An abstract log:
15 * A log consists of the following abstract entities:
16 * A level of detail, "log_level"
17 * A stream to which output should be sent
18 * A level of detail above which each statement should be
19 * immediately flushed.
20 * A (potentially empty) text name
21 *
22 * A log's current level of detail describes how "verbose" the logs
23 * should be. Each logging statement should have a detail associated
24 * with it; only statements whose level of detail are less than or
25 * equal to the log's level are printed. Others are (quickly) ignored.
26 * If a log's level is above the flush level, each statement is followed
27 * by an explicit flush on the stream.
28 *
29 * Each logging statement is stamped with the time of day, and day changes
30 * are noted in the log. Each logging statement is also stamped
31 * with the log's name, to allow multiple logs to (unambiguously) share
32 * the same stream. These routines are not thread safe.
33 */
34
35typedef struct ds_log_t ds_log_t; /* logs are opaque */
36
37/*** Observers ***/
38
39extern bool ds_log_valid(ds_log_t *lp);
40
41/*** Mutators ***/
42
43extern ds_log_t *ds_log_create(int loglevel, FILE *fp, int flushlevel,
44 char *name);
45
46extern FILE *ds_log_destroy(ds_log_t *lp);
47
48extern void ds_log_setlevel(ds_log_t *lp, int level);
49
50/*
51 * printmsg appends a newline: you don't need one.
52 * It's not a good idea to call this directly. Use DS_LOG_MSG
53 * instead;
54 */
55
56extern void ds_log_printmsg(ds_log_t *lp, int level, char *fmt, ...);
57
58/* Use the macro, DS_LOG_MSG to do logging: this will allow you to turn
59 off logging in performance-sensitive spots. */
60
61#define DS_LOG_MSG(args) ds_log_printmsg args
62
63#endif /* _DS_LOG_H_ */
bool ds_log_valid(ds_log_t *lp)
Definition: ds_log.c:44
void ds_log_setlevel(ds_log_t *lp, int level)
Definition: ds_log.c:88
FILE * ds_log_destroy(ds_log_t *lp)
Definition: ds_log.c:72
void ds_log_printmsg(ds_log_t *lp, int level, char *fmt,...)
Definition: ds_log.c:94
ds_log_t * ds_log_create(int loglevel, FILE *fp, int flushlevel, char *name)
Definition: ds_log.c:53
level
Definition: make_certs.py:100
name
Definition: pwdtopdbtool.py:40
Definition: ds_log.private.h:6
FILE * fp
Definition: ds_log.private.h:8