Claw
1.7.3
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
code
application.cpp
Go to the documentation of this file.
1
/*
2
CLAW - a C++ Library Absolutely Wonderful
3
4
CLAW is a free library without any particular aim but being useful to
5
anyone.
6
7
Copyright (C) 2005-2011 Julien Jorge
8
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2.1 of the License, or (at your option) any later version.
13
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
18
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23
contact: julien.jorge@gamned.org
24
*/
30
#include <
claw/application.hpp
>
31
32
#include <
claw/logger.hpp
>
33
#include <
claw/log_stream_uniq.hpp
>
34
#include <
claw/log_stream_concise.hpp
>
35
#include <
claw/claw_gettext.hpp
>
36
41
#define CLAW_MK_STR_(e) #e
42
47
#define CLAW_MK_STR(e) CLAW_MK_STR_(e)
48
49
/*----------------------------------------------------------------------------*/
58
claw::application::application
(
int
& argc,
char
** &argv )
59
: m_arguments( argc, argv )
60
{
61
setlocale( LC_ALL,
""
);
62
#ifdef CLAW_TEXT_DOMAIN_PATH
63
bindtextdomain(
"libclaw"
,
CLAW_MK_STR
(CLAW_TEXT_DOMAIN_PATH) );
64
#endif
65
bind_textdomain_codeset(
"libclaw"
,
"UTF-8"
);
66
textdomain(
"libclaw"
);
67
68
m_arguments
.
add_long
69
(
"--log-file"
,
claw_gettext
(
"The file to use to store log informations."
),
70
true
,
claw_gettext
(
"file"
) );
71
m_arguments
.
add_long
72
(
"--log-level"
,
73
claw_gettext
(
"Level of log informations:\n"
74
"\t\terror: error messages,\n"
75
"\t\twarning: warning and error messages,\n"
76
"\t\tverbose: all messages."
),
true
,
claw_gettext
(
"string"
) );
77
m_arguments
.
add_long
78
(
"--log-uniq"
,
79
claw_gettext
80
(
"Use a logger that does not output successively the same message."
),
81
true
);
82
m_arguments
.
add_long
83
(
"--log-concise"
,
84
claw_gettext
85
(
"Use a logger that does not output messages that have been recently"
86
" output."
),
true
,
claw_gettext
(
"integer"
) );
87
88
m_arguments
.
parse
( argc, argv );
89
90
log_stream
* log;
91
92
if
(
m_arguments
.
has_value
(
"--log-file"
) )
93
log =
new
file_logger
(
m_arguments
.
get_string
(
"--log-file"
) );
94
else
95
log =
new
console_logger
;
96
97
if
(
m_arguments
.
get_bool
(
"--log-uniq"
) )
98
log =
new
log_stream_uniq
(log);
99
else
if
(
m_arguments
.
has_value
(
"--log-concise"
)
100
&&
m_arguments
.
only_integer_values
(
"--log-concise"
)
101
&&
m_arguments
.
get_integer
(
"--log-concise"
) > 0 )
102
log =
new
log_stream_concise
(log,
m_arguments
.
get_integer
(
"--log-concise"
));
103
else
if
(
m_arguments
.
get_bool
(
"--log-concise"
) )
104
log =
new
log_stream_concise
(log);
105
106
logger
.
set
( log );
107
108
if
(
m_arguments
.
has_value
(
"--log-level"
) )
109
{
110
std::string level =
m_arguments
.
get_string
(
"--log-level"
);
111
112
if
( (level ==
"error"
) || (level ==
claw_gettext
(
"error"
)) )
113
logger
.
set_level
(
log_error
);
114
else
if
( (level ==
"warning"
) || (level ==
claw_gettext
(
"warning"
)) )
115
logger
.
set_level
(
log_warning
);
116
else
if
( (level ==
"verbose"
) || (level ==
claw_gettext
(
"verbose"
)) )
117
logger
.
set_level
(
log_verbose
);
118
else
119
logger
.
set_level
(
m_arguments
.
get_integer
(
"--log-level"
) );
120
}
121
122
}
// application::application()
123
124
/*----------------------------------------------------------------------------*/
128
claw::application::~application
()
129
{
130
logger
.
clear
();
131
}
// application::~application()
Generated on Thu Mar 14 2013 22:09:24 for Claw by
1.8.1.2