-
Notifications
You must be signed in to change notification settings - Fork 104
/
error_log.h
87 lines (74 loc) · 4.1 KB
/
error_log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Cherokee
*
* Authors:
* Alvaro Lopez Ortega <alvaro@alobbs.com>
*
* Copyright (C) 2001-2014 Alvaro Lopez Ortega
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#if !defined (CHEROKEE_INSIDE_CHEROKEE_H) && !defined (CHEROKEE_COMPILATION)
# error "Only <cherokee/cherokee.h> can be included directly, this file may disappear or change contents."
#endif
#ifndef CHEROKEE_ERROR_LOG_H
#define CHEROKEE_ERROR_LOG_H
#include <cherokee/common.h>
#include <cherokee/logger.h>
#include <cherokee/errors_defs.h>
typedef enum {
cherokee_err_warning,
cherokee_err_error,
cherokee_err_critical
} cherokee_error_type_t;
typedef struct {
int id;
const char *title;
const char *description;
const char *admin_url;
const char *debug;
int show_backtrace;
} cherokee_error_t;
#define CHEROKEE_ERROR(x) ((cherokee_error_t *)(x))
#if defined(__GNUC__) || ( defined(__SUNPRO_C) && __SUNPRO_C > 0x590 )
# define LOG_WARNING(e_num,arg...) cherokee_error_log (cherokee_err_warning, __FILE__, __LINE__, e_num, ##arg)
# define LOG_WARNING_S(e_num) cherokee_error_log (cherokee_err_warning, __FILE__, __LINE__, e_num)
# define LOG_ERROR(e_num,arg...) cherokee_error_log (cherokee_err_error, __FILE__, __LINE__, e_num, ##arg)
# define LOG_ERROR_S(e_num) cherokee_error_log (cherokee_err_error, __FILE__, __LINE__, e_num)
# define LOG_CRITICAL(e_num,arg...) cherokee_error_log (cherokee_err_critical, __FILE__, __LINE__, e_num, ##arg)
# define LOG_CRITICAL_S(e_num) cherokee_error_log (cherokee_err_critical, __FILE__, __LINE__, e_num)
# define LOG_ERRNO(syserror,type,e_num,arg...) cherokee_error_errno_log (syserror, type, __FILE__, __LINE__, e_num, ##arg)
# define LOG_ERRNO_S(syserror,type,e_num) cherokee_error_errno_log (syserror, type, __FILE__, __LINE__, e_num)
#else
# define LOG_WARNING(e_num,arg...) cherokee_error_log (cherokee_err_warning, __FILE__, __LINE__, e_num, __VA_ARGS__)
# define LOG_WARNING_S(e_num) cherokee_error_log (cherokee_err_warning, __FILE__, __LINE__, e_num)
# define LOG_ERROR(e_num,arg...) cherokee_error_log (cherokee_err_error, __FILE__, __LINE__, e_num, __VA_ARGS__)
# define LOG_ERROR_S(e_num) cherokee_error_log (cherokee_err_error, __FILE__, __LINE__, e_num)
# define LOG_CRITICAL(e_num,arg...) cherokee_error_log (cherokee_err_critical, __FILE__, __LINE__, e_num, __VA_ARGS__)
# define LOG_CRITICAL_S(e_num) cherokee_error_log (cherokee_err_critical, __FILE__, __LINE__, e_num)
# define LOG_ERRNO(syserror,type,e_num,arg...) cherokee_error_errno_log (syserror, type, __FILE__, __LINE__, e_num, __VA_ARGS__)
# define LOG_ERRNO_S(syserror,type,e_num) cherokee_error_errno_log (syserror, type, __FILE__, __LINE__, e_num)
#endif
ret_t cherokee_error_log (cherokee_error_type_t type,
const char *filename,
int line,
int error_num, ...);
ret_t cherokee_error_errno_log (int errnumber,
cherokee_error_type_t type,
const char *filename,
int line,
int error_num, ...);
ret_t cherokee_error_set_default (cherokee_logger_writer_t *writer);
#endif /* CHEROKEE_ERROR_LOG_H */