3
* Copyright © 2007 Scott James Remnant <scott@netsplit.com>.
3
* Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
4
* Copyright © 2009 Canonical Ltd.
5
6
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
7
* it under the terms of the GNU General Public License version 2, as
8
* published by the Free Software Foundation.
10
10
* This program is distributed in the hope that it will be useful,
11
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
20
#ifndef NIH_LOGGING_H
21
21
#define NIH_LOGGING_H
24
* These functions provide a logging interface for outputting messages
25
* at different priorities, and filtering based on them.
27
* The output for the logger can be selected using nih_log_set_logger(),
28
* where nih_logger_printf() is the default and nih_logger_syslog() another
29
* popular alternative.
31
* Log messages are output with different macros.
23
34
#include <stdlib.h>
25
36
#include <nih/macros.h>
52
63
* should not discard any messages and instead nih_log_set_priority() used
53
64
* to decide the treshold of logged messages.
55
* The logger may return non-zero to indicate that it was not able to
66
* Returns: zero on success, negative value if the logger was not able
67
* to output the message.
58
69
typedef int (*NihLogger) (NihLogLevel priority, const char *message);
157
NihLogLevel nih_log_priority;
168
extern NihLogLevel nih_log_priority;
171
void nih_log_init (void);
160
173
void nih_log_set_logger (NihLogger new_logger);
161
174
void nih_log_set_priority (NihLogLevel new_priority);