This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
73 lines (61 loc) · 2.47 KB
/
main.c
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
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
Copyright (C) 2011 Alexey Veretennikov (alexey dot veretennikov at gmail.com)
This file is part of liblogger.
liblogger is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
liblogger 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with liblogger. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#define MODULE_NAME "main"
#include "logger.h"
int main(int argc, char *argv[])
{
logger_parameters params;
params.log_level = LOG_LEVEL_NORMAL;
params.log_format = LOG_FORMAT_JSON;
if ( argc > 1)
{
params.log_file_path = argv[1];
params.log_rotate_count = argc > 2 ? atoi(argv[2]) : 0;
logger_init_with_params(¶ms);
}
else
logger_init();
printf("Log level ALL\n");
logger_set_log_level(LOG_LEVEL_ALL);
LOGERROR("some error!");
logger_write("normal",LOG_ENTRY_NORMAL,"the message: %s","normal");
logger_write("err",LOG_ENTRY_ERROR,"the message: %s","error");
logger_write("warn",LOG_ENTRY_WARNING,"the message: %s","warning");
logger_write("info",LOG_ENTRY_INFO,"the message: %s","info");
printf("Log level NORMAL\n");
logger_set_log_level(LOG_LEVEL_NORMAL);
logger_set_use_stdout(1);
logger_write("norm",LOG_ENTRY_NORMAL,"the message: %s","normal");
logger_write("err",LOG_ENTRY_ERROR,"the message: %s","error");
logger_write("warn",LOG_ENTRY_WARNING,"the message: %s","warning");
logger_write("info",LOG_ENTRY_INFO,"the message: %s","info");
printf("Log level ERRORS\n");
logger_set_log_level(LOG_LEVEL_ERRORS);
#ifndef LOGGER_MT
logger_event_start("main",LOG_ENTRY_NORMAL,"logging");
#endif
logger_write("norm",LOG_ENTRY_NORMAL,"the message: %s","normal");
logger_write("err",LOG_ENTRY_ERROR,"the message: %s","error");
logger_write("warn",LOG_ENTRY_WARNING,"the message: %s","warning");
logger_write("info",LOG_ENTRY_INFO,"the message: %s","info");
#ifndef LOGGER_MT
logger_event_end("main",LOG_ENTRY_NORMAL,"logging");
#endif
logger_fini();
return 0;
}