Debian Codegraph @

src/util/simplelog.h

raw symbols SCIP
1 /* simplelog.c - Simple logging subsystem for Poldi
2 Copyright (C) 2008 g10 Code GmbH
3
4 This file is part of Poldi.
5
6 Poldi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 Poldi is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20 #ifndef SIMPLELOG_H
21 #define SIMPLELOG_H
22
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 #include <gpg-error.h>
27
28 typedef struct log_handle *log_handle_t;
29
30 #define LOG_FLAG_WITH_PREFIX (1 << 0)
31 #define LOG_FLAG_WITH_TIME (1 << 1)
32 #define LOG_FLAG_WITH_PID (1 << 2)
33
34 typedef enum
35 {
36 LOG_BACKEND_NONE,
37 LOG_BACKEND_STREAM,
38 LOG_BACKEND_FILE,
39 LOG_BACKEND_SYSLOG
40 } log_backend_t;
41
42 typedef enum
43 {
44 LOG_LEVEL_DEBUG = 1,
45 LOG_LEVEL_INFO,
46 LOG_LEVEL_ERROR,
47 LOG_LEVEL_FATAL
48 } log_level_t;
49
50 #define LOG_PREFIX_LENGTH 128
51
52 gpg_error_t log_create (log_handle_t *handle);
53 void log_destroy (log_handle_t handle);
54
55 void log_set_flags (log_handle_t handle, unsigned int flags);
56 void log_unset_flags (log_handle_t handle, unsigned int flags);
57 void log_set_prefix (log_handle_t handle, const char *prefix);
58 void log_set_min_level (log_handle_t handle, log_level_t min_level);
59
60 gpg_error_t log_set_backend_stream (log_handle_t handle, FILE *fp);
61 gpg_error_t log_set_backend_file (log_handle_t handle, const char *filename);
62 gpg_error_t log_set_backend_syslog (log_handle_t handle);
63
64 gpg_error_t log_write (log_handle_t handle, log_level_t level,
65 const char *fmt, ...);
66 gpg_error_t log_write_va (log_handle_t handle, log_level_t level,
67 const char *fmt, va_list ap);
68
69 gpg_error_t log_msg_debug (log_handle_t handle, const char *fmt, ...);
70 gpg_error_t log_msg_info (log_handle_t handle, const char *fmt, ...);
71 gpg_error_t log_msg_error (log_handle_t handle, const char *fmt, ...);
72 gpg_error_t log_msg_fatal (log_handle_t handle, const char *fmt, ...);
73
74 #endif