~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to include/net-snmp/library/snmp_logging.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-09-13 12:06:21 UTC
  • Revision ID: james.westby@ubuntu.com-20040913120621-g952ntonlleihcvm
Tags: upstream-5.1.1
ImportĀ upstreamĀ versionĀ 5.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SNMP_LOGGING_H
 
2
#define SNMP_LOGGING_H
 
3
 
 
4
#ifdef __cplusplus
 
5
extern          "C" {
 
6
#endif
 
7
 
 
8
#if HAVE_SYSLOG_H
 
9
#include <syslog.h>
 
10
#endif
 
11
#if HAVE_STDARG_H
 
12
#include <stdarg.h>
 
13
#else
 
14
#include <varargs.h>
 
15
#endif
 
16
 
 
17
#ifndef LOG_ERR
 
18
#define LOG_EMERG       0       /* system is unusable */
 
19
#define LOG_ALERT       1       /* action must be taken immediately */
 
20
#define LOG_CRIT        2       /* critical conditions */
 
21
#define LOG_ERR         3       /* error conditions */
 
22
#define LOG_WARNING     4       /* warning conditions */
 
23
#define LOG_NOTICE      5       /* normal but significant condition */
 
24
#define LOG_INFO        6       /* informational */
 
25
#define LOG_DEBUG       7       /* debug-level messages */
 
26
#endif
 
27
 
 
28
    struct snmp_log_message {
 
29
        int             priority;
 
30
        const char     *msg;
 
31
    };
 
32
 
 
33
#ifndef DEFAULT_LOG_ID
 
34
#define DEFAULT_LOG_ID "net-snmp"
 
35
#endif
 
36
 
 
37
    void            init_snmp_logging(void);
 
38
    int             snmp_get_do_logging(void);
 
39
    void            snmp_disable_syslog(void);
 
40
    void            snmp_disable_filelog(void);
 
41
    void            snmp_disable_stderrlog(void);
 
42
    void            snmp_disable_calllog(void);
 
43
    void            snmp_disable_log(void);
 
44
    void            snmp_enable_syslog(void);
 
45
    void            snmp_enable_syslog_ident(const char *ident,
 
46
                                             const int   facility);
 
47
    void            snmp_enable_filelog(const char *logfilename,
 
48
                                        int dont_zero_log);
 
49
    void            snmp_enable_stderrlog(void);
 
50
    void            snmp_enable_calllog(void);
 
51
 
 
52
#if HAVE_STDARG_H
 
53
    int             snmp_log(int priority, const char *format, ...);
 
54
#else
 
55
    int             snmp_log(va_alist);
 
56
#endif
 
57
    int             snmp_vlog(int priority, const char *format,
 
58
                              va_list ap);
 
59
    /*
 
60
     * 0 - successful message formatting 
 
61
     */
 
62
    /*
 
63
     * -1 - Could not format log-string 
 
64
     */
 
65
    /*
 
66
     * -2 - Could not allocate memory for log-message 
 
67
     */
 
68
    /*
 
69
     * -3 - Log-message too long! 
 
70
     */
 
71
 
 
72
    void            snmp_log_perror(const char *s);
 
73
 
 
74
 
 
75
#define NETSNMP_LOGHANDLER_STDOUT       1
 
76
#define NETSNMP_LOGHANDLER_STDERR       2
 
77
#define NETSNMP_LOGHANDLER_FILE         3
 
78
#define NETSNMP_LOGHANDLER_SYSLOG       4
 
79
#define NETSNMP_LOGHANDLER_CALLBACK     5
 
80
 
 
81
    int snmp_log_options(char *optarg, int argc, char *const *argv);
 
82
    void snmp_log_options_usage(const char *lead, FILE *outf);
 
83
    typedef struct netsnmp_log_handler_s netsnmp_log_handler; 
 
84
    typedef int (NetsnmpLogHandler)(netsnmp_log_handler*, int, const char *);
 
85
 
 
86
    NetsnmpLogHandler log_handler_stdouterr;
 
87
    NetsnmpLogHandler log_handler_file;
 
88
    NetsnmpLogHandler log_handler_syslog;
 
89
    NetsnmpLogHandler log_handler_callback;
 
90
    NetsnmpLogHandler log_handler_null;
 
91
 
 
92
    struct netsnmp_log_handler_s {
 
93
        int     enabled;
 
94
        int     priority;
 
95
        int     pri_max;
 
96
        int     type;
 
97
        const char *token;              /* Also used for filename */
 
98
 
 
99
        NetsnmpLogHandler       *handler;
 
100
 
 
101
        int     imagic;         /* E.g. file descriptor, syslog facility */
 
102
        void   *magic;          /* E.g. Callback function */
 
103
 
 
104
        netsnmp_log_handler     *next, *prev;
 
105
    };
 
106
 
 
107
netsnmp_log_handler *get_logh_head( void );
 
108
netsnmp_log_handler *netsnmp_register_loghandler( int type, int pri );
 
109
netsnmp_log_handler *netsnmp_find_loghandler( const char *token );
 
110
int netsnmp_add_loghandler(    netsnmp_log_handler *logh );
 
111
int netsnmp_remove_loghandler( netsnmp_log_handler *logh );
 
112
int netsnmp_enable_loghandler( const char *token );
 
113
int netsnmp_disable_loghandler( const char *token );
 
114
#ifdef __cplusplus
 
115
}
 
116
#endif
 
117
#endif                          /* SNMP_LOGGING_H */