Welcome to mirror list, hosted at ThFree Co, Russian Federation.

log.h « include - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 24d233ac949f90b3baef0b975a5793731c69655a (plain)
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
88
89
90
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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.
**/

#ifndef ZABBIX_LOG_H
#define ZABBIX_LOG_H

#include "zbxcommon.h"

#define LOG_LEVEL_EMPTY		0	/* printing nothing (if not LOG_LEVEL_INFORMATION set) */
#define LOG_LEVEL_CRIT		1
#define LOG_LEVEL_ERR		2
#define LOG_LEVEL_WARNING	3
#define LOG_LEVEL_DEBUG		4
#define LOG_LEVEL_TRACE		5

#define LOG_LEVEL_INFORMATION	127	/* printing in any case no matter what level set */

#define LOG_TYPE_UNDEFINED	0
#define LOG_TYPE_SYSTEM		1
#define LOG_TYPE_FILE		2
#define LOG_TYPE_CONSOLE	3

#define ZBX_OPTION_LOGTYPE_SYSTEM	"system"
#define ZBX_OPTION_LOGTYPE_FILE		"file"
#define ZBX_OPTION_LOGTYPE_CONSOLE	"console"

#define LOG_ENTRY_INTERVAL_DELAY	60	/* seconds */

extern int	zbx_log_level;
#define ZBX_CHECK_LOG_LEVEL(level)			\
		((LOG_LEVEL_INFORMATION != (level) &&	\
		((level) > zbx_log_level || LOG_LEVEL_EMPTY == (level))) ? FAIL : SUCCEED)

#ifdef HAVE___VA_ARGS__
#	define ZBX_ZABBIX_LOG_CHECK
#	define zabbix_log(level, ...)									\
													\
	do												\
	{												\
		if (SUCCEED == ZBX_CHECK_LOG_LEVEL(level))						\
			__zbx_zabbix_log(level, __VA_ARGS__);						\
	}												\
	while (0)
#else
#	define zabbix_log __zbx_zabbix_log
#endif

int		zabbix_open_log(int type, int level, const char *filename, char **error);
void		__zbx_zabbix_log(int level, const char *fmt, ...) __zbx_attr_format_printf(2, 3);
void		zabbix_close_log(void);

#ifndef _WINDOWS
int		zabbix_increase_log_level(void);
int		zabbix_decrease_log_level(void);
const char	*zabbix_get_log_level_string(void);
#endif

char		*zbx_strerror(int errnum);
char		*strerror_from_system(unsigned long error);

#ifdef _WINDOWS
char		*strerror_from_module(unsigned long error, const wchar_t *module);
#endif

int		zbx_redirect_stdio(const char *filename);

void		zbx_handle_log(void);

int		zbx_get_log_type(const char *logtype);
int		zbx_validate_log_parameters(ZBX_TASK_EX *task);

void	zbx_strlog_alloc(int level, char **out, size_t *out_alloc, size_t *out_offset, const char *format,
		...) __zbx_attr_format_printf(5, 6);
#endif