glog
src
glog
log_severity.h
Go to the documentation of this file.
1
// Copyright (c) 2007, Google Inc.
2
// All rights reserved.
3
//
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are
6
// met:
7
//
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above
11
// copyright notice, this list of conditions and the following disclaimer
12
// in the documentation and/or other materials provided with the
13
// distribution.
14
// * Neither the name of Google Inc. nor the names of its
15
// contributors may be used to endorse or promote products derived from
16
// this software without specific prior written permission.
17
//
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
#ifndef BASE_LOG_SEVERITY_H__
31
#define BASE_LOG_SEVERITY_H__
32
33
// The recommended semantics of the log levels are as follows:
34
//
35
// INFO:
36
// Use for state changes or other major events, or to aid debugging.
37
// WARNING:
38
// Use for undesired but relatively expected events, which may indicate a
39
// problem
40
// ERROR:
41
// Use for undesired and unexpected events that the program can recover from.
42
// All ERRORs should be actionable - it should be appropriate to file a bug
43
// whenever an ERROR occurs in production.
44
// FATAL:
45
// Use for undesired and unexpected events that the program cannot recover
46
// from.
47
48
// Variables of type LogSeverity are widely taken to lie in the range
49
// [0, NUM_SEVERITIES-1]. Be careful to preserve this assumption if
50
// you ever need to change their values or add a new severity.
51
typedef
int
LogSeverity
;
52
53
const
int
GLOG_INFO
= 0,
GLOG_WARNING
= 1,
GLOG_ERROR
= 2,
GLOG_FATAL
= 3,
54
NUM_SEVERITIES
= 4;
55
#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
56
# ifdef ERROR
57
# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
58
# endif
59
const
int
INFO
=
GLOG_INFO
,
WARNING
=
GLOG_WARNING
,
60
ERROR
=
GLOG_ERROR
,
FATAL
=
GLOG_FATAL
;
61
#endif
62
63
// DFATAL is FATAL in debug mode, ERROR in normal mode
64
#ifdef NDEBUG
65
#define DFATAL_LEVEL ERROR
66
#else
67
#define DFATAL_LEVEL FATAL
68
#endif
69
70
extern
GLOG_EXPORT
const
char
*
const
LogSeverityNames
[
NUM_SEVERITIES
];
71
72
// NDEBUG usage helpers related to (RAW_)DCHECK:
73
//
74
// DEBUG_MODE is for small !NDEBUG uses like
75
// if (DEBUG_MODE) foo.CheckThatFoo();
76
// instead of substantially more verbose
77
// #ifndef NDEBUG
78
// foo.CheckThatFoo();
79
// #endif
80
//
81
// IF_DEBUG_MODE is for small !NDEBUG uses like
82
// IF_DEBUG_MODE( string error; )
83
// DCHECK(Foo(&error)) << error;
84
// instead of substantially more verbose
85
// #ifndef NDEBUG
86
// string error;
87
// DCHECK(Foo(&error)) << error;
88
// #endif
89
//
90
#ifdef NDEBUG
91
enum
{
DEBUG_MODE
= 0 };
92
#define IF_DEBUG_MODE(x)
93
#else
94
enum
{
DEBUG_MODE
= 1 };
95
#define IF_DEBUG_MODE(x) x
96
#endif
97
98
#endif // BASE_LOG_SEVERITY_H__
INFO
const int INFO
Definition:
log_severity.h:59
ERROR
const int ERROR
Definition:
log_severity.h:60
FATAL
const int FATAL
Definition:
log_severity.h:60
GLOG_INFO
const int GLOG_INFO
Definition:
log_severity.h:53
LogSeverity
int LogSeverity
Definition:
log_severity.h:51
WARNING
const int WARNING
Definition:
log_severity.h:59
GLOG_EXPORT
#define GLOG_EXPORT
Definition:
glog/src/googletest.h:76
LogSeverityNames
const GLOG_EXPORT char *const LogSeverityNames[NUM_SEVERITIES]
Definition:
logging.cc:404
GLOG_WARNING
const int GLOG_WARNING
Definition:
log_severity.h:53
GLOG_FATAL
const int GLOG_FATAL
Definition:
log_severity.h:53
GLOG_ERROR
const int GLOG_ERROR
Definition:
log_severity.h:53
DEBUG_MODE
@ DEBUG_MODE
Definition:
log_severity.h:94
NUM_SEVERITIES
const int NUM_SEVERITIES
Definition:
log_severity.h:54
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:55