E-MailRelay

glog.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file glog.h
19///
20
21#ifndef G_LOG_H
22#define G_LOG_H
23
24#include "gdef.h"
25#include "glogstream.h"
26#include "glogoutput.h"
27
28#define G_LOG_IMP( expr , severity ) do { if(G::LogOutput::Instance::at(severity)) { auto log_stream = G::LogOutput::Instance::start((severity),__FILE__,__LINE__) ; log_stream << expr ; G::LogOutput::Instance::output(log_stream) ; } } while(0) /* NOLINT bugprone-macro-parentheses */
29#define G_LOG_IMP_IF( cond , expr , severity ) do { if(G::LogOutput::Instance::at(severity)&&(cond)) { auto log_stream = G::LogOutput::Instance::start((severity),__FILE__,__LINE__) ; log_stream << expr ; G::LogOutput::Instance::output(log_stream) ; } } while(0) /* NOLINT bugprone-macro-parentheses */
30#define G_LOG_IMP_ONCE( expr , severity ) do { static bool done__ = false ; if(!done__&&G::LogOutput::Instance::at(severity)) { auto log_stream = G::LogOutput::Instance::start((severity),__FILE__,__LINE__) ; log_stream << expr ; G::LogOutput::Instance::output(log_stream) ; } done__ = true ; } while(0) /* NOLINT bugprone-macro-parentheses */
31
32#if defined(G_WITH_DEBUG) || ( defined(_DEBUG) && ! defined(G_NO_DEBUG) )
33#define G_DEBUG( expr ) G_LOG_IMP( expr , G::LogOutput::Severity::Debug )
34#define G_DEBUG_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::LogOutput::Severity::Debug )
35#define G_DEBUG_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::LogOutput::Severity::Debug )
36#else
37#define G_DEBUG( expr )
38#define G_DEBUG_IF( cond , expr )
39#define G_DEBUG_ONCE( group , expr )
40#endif
41
42#if ! defined(G_NO_LOG)
43#define G_LOG( expr ) G_LOG_IMP( expr , G::LogOutput::Severity::InfoVerbose )
44#define G_LOG_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::LogOutput::Severity::InfoVerbose )
45#define G_LOG_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::LogOutput::Severity::InfoVerbose )
46#else
47#define G_LOG( expr )
48#define G_LOG_IF( cond , expr )
49#define G_LOG_ONCE( expr )
50#endif
51
52#if ! defined(G_NO_LOG_MORE)
53#define G_LOG_MORE( expr ) G_LOG_IMP( expr , G::LogOutput::Severity::InfoMoreVerbose )
54#define G_LOG_MORE_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::LogOutput::Severity::InfoMoreVerbose )
55#define G_LOG_MORE_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::LogOutput::Severity::InfoMoreVerbose )
56#else
57#define G_LOG_MORE( expr )
58#define G_LOG_MORE_IF( cond , expr )
59#define G_LOG_MORE_ONCE( expr )
60#endif
61
62#if ! defined(G_NO_LOG_S)
63#define G_LOG_S( expr ) G_LOG_IMP( expr , G::LogOutput::Severity::InfoSummary )
64#define G_LOG_S_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::LogOutput::Severity::InfoSummary )
65#define G_LOG_S_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::LogOutput::Severity::InfoSummary )
66#else
67#define G_LOG_S( expr )
68#define G_LOG_S_IF( cond , expr )
69#define G_LOG_S_ONCE( expr )
70#endif
71
72#if ! defined(G_NO_WARNING)
73#define G_WARNING( expr ) G_LOG_IMP( expr , G::LogOutput::Severity::Warning )
74#define G_WARNING_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::LogOutput::Severity::Warning )
75#define G_WARNING_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::LogOutput::Severity::Warning )
76#else
77#define G_WARNING( expr )
78#define G_WARNING_IF( cond , expr )
79#define G_WARNING_ONCE( expr )
80#endif
81
82#if ! defined(G_NO_ERROR)
83#define G_ERROR( expr ) G_LOG_IMP( expr , G::LogOutput::Severity::Error )
84#else
85#define G_ERROR( expr )
86#endif
87
88#endif
glogoutput.h
glogstream.h