1
/* Copyright (C) 2004 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; either version 2 of the License, or
6
(at your option) any later version.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
#include "sb_options.h"
28
/* Macros to log per-request execution statistics */
30
#define LOG_EVENT_START(msg, thread_id) \
33
sb_timer_start(&sb_globals.op_timers[thread_id]); \
34
((log_msg_oper_t *)(msg).data)->action = LOG_MSG_OPER_START; \
38
#define LOG_EVENT_STOP(msg, thread_id) \
41
((log_msg_oper_t *)(msg).data)->action = LOG_MSG_OPER_STOP; \
43
sb_timer_stop(&sb_globals.op_timers[thread_id]); \
46
/* Message types definition */
49
LOG_MSG_TYPE_MIN, /* used for internal purposes */
50
LOG_MSG_TYPE_TEXT, /* arbitrary text messages */
51
LOG_MSG_TYPE_OPER, /* operation start/stop messages */
52
LOG_MSG_TYPE_MAX /* used for internal purposes */
55
/* Message priorities definition */
58
LOG_FATAL, /* system is unusable */
59
LOG_ALERT, /* user actions must be taken */
60
LOG_WARNING, /* warnings */
61
LOG_NOTICE, /* normal but significant messages */
62
LOG_INFO, /* informational messages */
63
LOG_DEBUG, /* debug-level messages */
64
LOG_MAX /* used for internal purposes */
67
/* Text message definition */
70
log_msg_priority_t priority;
74
/* Operation start/stop message definition */
79
} log_msg_oper_action_t;
82
log_msg_oper_action_t action;
86
/* General log message definition */
93
/* Log handler operations definition */
95
typedef int log_op_register(void); /* register handler options */
96
typedef int log_op_init(void); /* initialize log handler */
97
typedef int log_op_process(log_msg_t *msg); /* process message */
98
typedef int log_op_done(void); /* uninitialize log handler */
100
/* Log handler operations structure */
104
log_op_process *process;
108
/* Log handler definition */
111
log_handler_ops_t ops; /* handler operations */
112
sb_arg_t *args; /* handler arguments */
114
sb_list_item_t listitem; /* can be linked in a list */
117
/* Register logger */
119
int log_register(void);
121
/* Initialize logger */
125
/* Add handler for a specified type of messages */
127
int log_add_handler(log_msg_type_t type, log_handler_t *handler);
129
/* Main function to dispatch log messages */
131
void log_msg(log_msg_t *);
133
/* printf-like wrapper to log text messages */
135
void log_text(log_msg_priority_t priority, const char *fmt, ...);
137
/* printf-like wrapper to log system error messages */
139
void log_errno(log_msg_priority_t priority, const char *fmt, ...);
141
/* Uninitialize logger */
145
#endif /* SB_LOGGER_H */