Bayeux  3.4.1
Core Foundation library for SuperNEMO
logger.h
Go to the documentation of this file.
1 //
36 // Copyright (c) 2013 by Ben Morgan <bmorgan.warwick@gmail.com>
37 // Copyright (c) 2013 by The University of Warwick
38 // Copyright (c) 2016-2018 by François Mauger <mauger@lpccaen.inp3.fr>
39 // Copyright (c) 2016-2018 by Université de Caen Normandie
40 //
41 // This file is part of datatools.
42 //
43 // datatools is free software: you can redistribute it and/or modify
44 // it under the terms of the GNU General Public License as published by
45 // the Free Software Foundation, either version 3 of the License, or
46 // (at your option) any later version.
47 //
48 // datatools is distributed in the hope that it will be useful,
49 // but WITHOUT ANY WARRANTY; without even the implied warranty of
50 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 // GNU General Public License for more details.
52 //
53 // You should have received a copy of the GNU General Public License
54 // along with datatools. If not, see <http://www.gnu.org/licenses/>.
55 
56 #ifndef DATATOOLS_LOGGER_H
57 #define DATATOOLS_LOGGER_H
58 
59 // Standard Library:
60 #include <iostream>
61 
62 // Third Party:
63 // - Boost:
64 #include "boost/current_function.hpp"
65 
66 // This project:
67 #ifndef Q_MOC_RUN
69 #endif // Q_MOC_RUN
70 
72 namespace datatools {
73 
74  // Forward declarations:
75  class properties;
76  class object_configuration_description;
77 
79  struct logger {
80 
82  enum priority {
83  PRIO_ALWAYS = -1,
93  };
94 
102  static priority get_priority(const std::string& name);
103 
108  static std::string get_priority_label(priority p_);
109 
113  static bool is_undefined(priority p_);
114 
118  static bool is_fatal(priority p_);
119 
123  static bool is_critical(priority p_);
124 
128  static bool is_error(priority p_);
129 
133  static bool is_warning(priority p_);
134 
138  static bool is_notice(priority p_);
139 
143  static bool is_information(priority p_);
144 
148  static bool is_debug(priority p_);
149 
153  static bool is_trace(priority p_);
154 
180  priority default_prio_ = datatools::logger::PRIO_FATAL,
181  bool throw_on_error_ = true);
182 
184  const std::string & default_value_ = "fatal",
185  const std::string & prefix_ = "",
186  const std::string & from_ = "");
187 
188  };
189 
190 } // namespace datatools
191 
192 #ifndef Q_MOC_RUN
193 // Activate reflection layer for the 'datatools::logger::priority' enum:
194 DR_TYPE_INIT(::datatools::logger) // mandatory to access the embedded enum
196 #endif // Q_MOC_RUN
197 
199 
200 #endif // DATATOOLS_LOGGER_H
201 
202 // Local Variables: --
203 // mode: c++ --
204 // c-file-style: "gnu" --
205 // tab-width: 2 --
206 // End: --
A notice, which is an information with just a higher priority.
Definition: logger.h:89
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
An informational message, usually denoting the successful completion of an operation.
Definition: logger.h:90
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
static priority get_priority(const std::string &name)
An error. An operation did not complete successfully, but the application as a whole is not affected.
Definition: logger.h:87
static bool is_trace(priority p_)
static bool is_undefined(priority p_)
Macros associated to logging utilities.
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
Undefined/invalid priority.
Definition: logger.h:84
static bool is_warning(priority p_)
Always print the message.
Definition: logger.h:83
static bool is_debug(priority p_)
static bool is_notice(priority p_)
Organise logging functionality under one roof.
Definition: logger.h:79
static bool is_error(priority p_)
static bool is_fatal(priority p_)
static priority extract_logging_configuration(const datatools::properties &config_, priority default_prio_=datatools::logger::PRIO_FATAL, bool throw_on_error_=true)
A debugging message.
Definition: logger.h:91
A critical error. The application might not be able to continue running successfully.
Definition: logger.h:86
A tracing message. This is the lowest priority.
Definition: logger.h:92
static bool is_critical(priority p_)
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
static void declare_ocd_logging_configuration(datatools::object_configuration_description &, const std::string &default_value_="fatal", const std::string &prefix_="", const std::string &from_="")
static bool is_information(priority p_)
#define DR_TYPE_INIT(Introspectable)
Definition: reflection_interface.h:165
A warning. An operation completed with an unexpected result.
Definition: logger.h:88
static std::string get_priority_label(priority p_)
A dictionary of arbitrary properties.
Definition: properties.h:125