LogMacros.h
Go to the documentation of this file.
// 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.
#ifndef SURGSIM_FRAMEWORK_LOGMACROS_H
#define SURGSIM_FRAMEWORK_LOGMACROS_H
#include "SurgSim/Framework/Logger.h"
#include "SurgSim/Framework/LogMessage.h"
namespace SurgSim
{
namespace Framework
{
#define SURGSIM_LOG_LEVEL(level) ::SurgSim::Framework::LOG_LEVEL_ ## level
#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))
#define SURGSIM_LOG_DEBUG(logger) SURGSIM_LOG(logger, DEBUG)
#define SURGSIM_LOG_INFO(logger) SURGSIM_LOG(logger, INFO)
#define SURGSIM_LOG_WARNING(logger) SURGSIM_LOG(logger, WARNING)
#define SURGSIM_LOG_SEVERE(logger) SURGSIM_LOG(logger, SEVERE)
#define SURGSIM_LOG_CRITICAL(logger) SURGSIM_LOG(logger, CRITICAL)
#define SURGSIM_LOG_IF(condition, logger, level) \
if (! (condition)) \
{ \
} \
else \
/* important: no curly braces around this! */ \
SURGSIM_LOG(logger, level)
#define SURGSIM_FLAG_VARIABLE_NAME_HELPER(base, line) base ## line
#define SURGSIM_FLAG_VARIABLE_NAME(base, line) SURGSIM_FLAG_VARIABLE_NAME_HELPER(base, line)
#define SURGSIM_LOG_ONCE_VARIABLE SURGSIM_FLAG_VARIABLE_NAME(surgsimLogOnceFlag, __LINE__)
#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)
#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
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
LogMessage.h
Logger.h