Cambridge SMT System
logger.openfstglog.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use these files except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 // Copyright 2012 - Gonzalo Iglesias, Adrià de Gispert, William Byrne
14 
22 #ifndef LOGGER_OPENFSTGLOG_HPP
23 #define LOGGER_OPENFSTGLOG_HPP
24 
25 namespace ucam {
26 namespace util {
27 
33 inline void initLogger ( int argc, const char *argv[] ) {
34  bool verbose = false;
35  const std::string lv = "--" + HifstConstants::kLoggerVerbose;
36  for ( uint k = 0; k < argc; ++k ) {
37  if ( !strcmp ( argv[k], lv.c_str() ) ) {
38  verbose = true;
39  break;
40  }
41  }
42  silent::set ( !verbose );
43 };
44 
45 }
46 }
47 
48 #ifdef PRINTINFO
49 #define LINFO(msg) if (!::ucam::util::silent::get()) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".INF:" << msg ;
50 #define FORCELINFO(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__) << ".INF:" << msg ;
51 #else
52 #define LINFO(msg)
53 #define FORCELINFO(msg)
54 #endif
55 
56 #ifdef PRINTDEBUG3
57 #ifndef PRINTDEBUG2
58 #define PRINTDEBUG2
59 #endif
60 #define LDEBUG3(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".DBG3:" << msg ;
61 #else
62 #define LDEBUG3(msg)
63 #endif
64 
65 #ifdef PRINTDEBUG2
66 #ifndef PRINTDEBUG1
67 #define PRINTDEBUG1
68 #endif
69 #define LDEBUG2(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".DBG2:" << msg ;
70 #else
71 #define LDEBUG2(msg)
72 #endif
73 
74 #ifdef PRINTDEBUG1
75 #ifndef PRINTDEBUG
76 #define PRINTDEBUG
77 #endif
78 #define LDEBUG1(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".DBG1:" << msg ;
79 #define LDEBUG(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".DBG1:" << msg ;
80 #else
81 #define LDEBUG(msg)
82 #endif
83 
84 #ifdef PRINTDEBUG
85 #define LDBG_EXECUTE(order) {order;}
86 #else
87 #define LDBG_EXECUTE(order)
88 #endif
89 
90 #ifdef PRINTERROR
91 #define LERROR(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".ERR:" << msg ;
92 #else
93 #define LERROR(msg)
94 #endif
95 
96 #ifdef PRINTWARNING
97 #define LWARN(msg) TRACER << ::ucam::util::filteredHeader(::ucam::util::detailed?__PRETTY_FUNCTION__:__func__)<< ".WRN:" << msg ;
98 #else
99 #define LWARN(msg)
100 #endif
101 
102 #endif
void initLogger(int argc, const char *argv[])
Inits logger, parses param options checking for –logger.verbose.
static void set(bool silent)
Set silent mode or viceversa.
Definition: logger.hpp:44
const std::string kLoggerVerbose
Definition: logger.hpp:25
Definition: bleu.hpp:14