/usr/include/SurgSim/Framework/LogMacros.h is in libopensurgsim-dev 0.7.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | // This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/// \file
/// Macros used for logging.
/// \ingroup logInternals
/// \sa loggingAPI
#ifndef SURGSIM_FRAMEWORK_LOGMACROS_H
#define SURGSIM_FRAMEWORK_LOGMACROS_H
#include "SurgSim/Framework/Logger.h"
#include "SurgSim/Framework/LogMessage.h"
namespace SurgSim
{
namespace Framework
{
/// \addtogroup loggingAPI
/// @{
/// Converts a short level name to the log level enum value.
/// \param level Short log level name
/// (\link SurgSim::Framework::LOG_LEVEL_DEBUG DEBUG\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_INFO INFO\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_WARNING WARNING\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_SEVERE SEVERE\endlink or
/// \link SurgSim::Framework::LOG_LEVEL_CRITICAL CRITICAL\endlink).
/// \return Log level \link SurgSim::Framework::LogLevel enum value\endlink.
/// \ingroup logInternals
#define SURGSIM_LOG_LEVEL(level) ::SurgSim::Framework::LOG_LEVEL_ ## level
/// Logs a message to the specified \c logger with the short \c level name.
/// \param logger Logger used to log the message
/// \param level Level of this log message
/// (\link SurgSim::Framework::LOG_LEVEL_DEBUG DEBUG\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_INFO INFO\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_WARNING WARNING\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_SEVERE SEVERE\endlink or
/// \link SurgSim::Framework::LOG_LEVEL_CRITICAL CRITICAL\endlink).
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG(logger, WARNING) << messageText;
/// ~~~~
#define SURGSIM_LOG(logger, level) \
if (SURGSIM_LOG_LEVEL(level) < (logger)->getThreshold()) \
{ \
} \
else \
/* important: no curly braces around this! */ \
::SurgSim::Framework::LogMessage((logger), SURGSIM_LOG_LEVEL(level))
/// Logs a message to the specified \c logger at the \link SurgSim::Framework::LOG_LEVEL_DEBUG DEBUG\endlink level.
/// \param logger Logger used to log the message
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_DEBUG(logger) << messageText;
/// ~~~~
#define SURGSIM_LOG_DEBUG(logger) SURGSIM_LOG(logger, DEBUG)
/// Logs a message to the specified \c logger at the \link SurgSim::Framework::LOG_LEVEL_INFO INFO\endlink level.
/// \param logger Logger used to log the message
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_INFO(logger) << messageText;
/// ~~~~
#define SURGSIM_LOG_INFO(logger) SURGSIM_LOG(logger, INFO)
/// Logs a message to the specified \c logger at the \link SurgSim::Framework::LOG_LEVEL_WARNING WARNING\endlink level.
/// \param logger Logger used to log the message
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_WARNING(logger) << messageText;
/// ~~~~
#define SURGSIM_LOG_WARNING(logger) SURGSIM_LOG(logger, WARNING)
/// Logs a message to the specified \c logger at the \link SurgSim::Framework::LOG_LEVEL_SEVERE SEVERE\endlink level.
/// \param logger Logger used to log the message
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_SEVERE(logger) << messageText;
/// ~~~~
#define SURGSIM_LOG_SEVERE(logger) SURGSIM_LOG(logger, SEVERE)
/// Logs a message to the specified \c logger at the \link SurgSim::Framework::LOG_LEVEL_CRITICAL CRITICAL\endlink
/// level.
/// \param logger Logger used to log the message
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_CRITICAL(logger) << messageText;
/// ~~~~
#define SURGSIM_LOG_CRITICAL(logger) SURGSIM_LOG(logger, CRITICAL)
/// Logs a message to the specified \c logger with the short \c level name if \c condition is true.
/// \param condition Condition to test.
/// \param logger Logger used to log the message.
/// \param level Level of this log message
/// (\link SurgSim::Framework::LOG_LEVEL_DEBUG DEBUG\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_INFO INFO\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_WARNING WARNING\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_SEVERE SEVERE\endlink or
/// \link SurgSim::Framework::LOG_LEVEL_CRITICAL CRITICAL\endlink).
/// \return Stream to output the log message.
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_IF(size >= 100, logger, INFO) << "size is " << size;
/// ~~~~
#define SURGSIM_LOG_IF(condition, logger, level) \
if (! (condition)) \
{ \
} \
else \
/* important: no curly braces around this! */ \
SURGSIM_LOG(logger, level)
/// Generate a variable name that should be unique within a file.
/// The name will be unique unless this macro is used twice on the same source code line, e.g. due to macro expansion.
/// Two macros are needed to make sure the argument is fully expanded.
/// \ingroup logInternals
#define SURGSIM_FLAG_VARIABLE_NAME_HELPER(base, line) base ## line
/// Generate a variable name that should be unique within a file.
/// The name will be unique unless this macro is used twice on the same source code line, e.g. due to macro expansion.
/// Two macros are needed to make sure the argument is fully expanded.
/// \ingroup logInternals
#define SURGSIM_FLAG_VARIABLE_NAME(base, line) SURGSIM_FLAG_VARIABLE_NAME_HELPER(base, line)
/// Define a variable name that depends on the line number in the source file where the macro is called from.
/// We need this because we can't just add braces to create a scope; that would break using << to add more info.
/// \ingroup logInternals
#define SURGSIM_LOG_ONCE_VARIABLE SURGSIM_FLAG_VARIABLE_NAME(surgsimLogOnceFlag, __LINE__)
/// Logs a message to the specified \c logger with the short \c level name, but only the first time this statement
/// is reached.
/// \param logger Logger used to log the message.
/// \param level Level of this log message
/// (\link SurgSim::Framework::LOG_LEVEL_DEBUG DEBUG\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_INFO INFO\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_WARNING WARNING\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_SEVERE SEVERE\endlink or
/// \link SurgSim::Framework::LOG_LEVEL_CRITICAL CRITICAL\endlink).
/// \return Stream to output the log message.
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_ONCE(logger, level) << messageTextShownOnce;
/// ~~~~
#define SURGSIM_LOG_ONCE(logger, level) \
static int SURGSIM_LOG_ONCE_VARIABLE = 0; \
if ((SURGSIM_LOG_ONCE_VARIABLE++) != 0) \
{ \
} \
else \
/* important: no curly braces around this! */ \
SURGSIM_LOG(logger, level)
/// Logs a message to the specified \c logger with the short \c level name if \c condition is true, but only the
/// first time *this* particular condition is true.
/// \param condition Condition to test
/// \param logger Logger used to log the message
/// \param level Level of this log message
/// (\link SurgSim::Framework::LOG_LEVEL_DEBUG DEBUG\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_INFO INFO\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_WARNING WARNING\endlink,
/// \link SurgSim::Framework::LOG_LEVEL_SEVERE SEVERE\endlink or
/// \link SurgSim::Framework::LOG_LEVEL_CRITICAL CRITICAL\endlink).
/// \return Stream to output the log message
///
/// \b Example
/// ~~~~
/// SURGSIM_LOG_ONCE_IF(condition, logger, level) << messageTextShownOnce;
/// ~~~~
#define SURGSIM_LOG_ONCE_IF(condition, logger, level) \
static int SURGSIM_LOG_ONCE_VARIABLE = 0; \
if (! (condition)) \
{ \
} \
else if ((SURGSIM_LOG_ONCE_VARIABLE++) != 0) \
{ \
} \
else \
/* important: no curly braces around this! */ \
SURGSIM_LOG(logger, level)
/// @}
}; // namespace Framework
}; // namespace SurgSim
#endif // SURGSIM_FRAMEWORK_LOGMACROS_H
|