Skip to content

Commit

Permalink
rename log levels to prevent conflicts with syslog.h (ros#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioan Sucan committed Apr 12, 2013
1 parent 49a9782 commit 75d8571
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions include/console_bridge/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
\}
*/
#define logError(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::LOG_ERROR, fmt, ##__VA_ARGS__)
#define logError(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_ERROR, fmt, ##__VA_ARGS__)

#define logWarn(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::LOG_WARN, fmt, ##__VA_ARGS__)
#define logWarn(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_WARN, fmt, ##__VA_ARGS__)

#define logInform(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::LOG_INFO, fmt, ##__VA_ARGS__)
#define logInform(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_INFO, fmt, ##__VA_ARGS__)

#define logDebug(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::LOG_DEBUG, fmt, ##__VA_ARGS__)
#define logDebug(fmt, ...) console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_DEBUG, fmt, ##__VA_ARGS__)


/** \brief Message namespace. This contains classes needed to
Expand All @@ -78,11 +78,11 @@ namespace console_bridge
/** \brief The set of priorities for message logging */
enum LogLevel
{
LOG_DEBUG = 0,
LOG_INFO,
LOG_WARN,
LOG_ERROR,
LOG_NONE
CONSOLE_BRIDGE_LOG_DEBUG = 0,
CONSOLE_BRIDGE_LOG_INFO,
CONSOLE_BRIDGE_LOG_WARN,
CONSOLE_BRIDGE_LOG_ERROR,
CONSOLE_BRIDGE_LOG_NONE
};

/** \brief Generic class to handle output from a piece of
Expand Down
6 changes: 3 additions & 3 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct DefaultOutputHandler
{
output_handler_ = static_cast<console_bridge::OutputHandler*>(&std_output_handler_);
previous_output_handler_ = output_handler_;
logLevel_ = console_bridge::LOG_WARN;
logLevel_ = console_bridge::CONSOLE_BRIDGE_LOG_WARN;
}

console_bridge::OutputHandlerSTD std_output_handler_;
Expand Down Expand Up @@ -133,7 +133,7 @@ static const char* LogLevelString[4] = {"Debug: ", "Info: ", "Warning: ", "

void console_bridge::OutputHandlerSTD::log(const std::string &text, LogLevel level, const char *filename, int line)
{
if (level >= LOG_WARN)
if (level >= CONSOLE_BRIDGE_LOG_WARN)
{
std::cerr << LogLevelString[level] << text << std::endl;
std::cerr << " at line " << line << " in " << filename << std::endl;
Expand Down Expand Up @@ -165,7 +165,7 @@ void console_bridge::OutputHandlerFile::log(const std::string &text, LogLevel le
if (file_)
{
fprintf(file_, "%s%s\n", LogLevelString[level], text.c_str());
if(level >= LOG_WARN)
if(level >= CONSOLE_BRIDGE_LOG_WARN)
fprintf(file_, " at line %d in %s\n", line, filename);
fflush(file_);
}
Expand Down

0 comments on commit 75d8571

Please sign in to comment.