Skip to content

Commit

Permalink
Restore CFString code
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Aug 4, 2023
1 parent 3cae7a1 commit 7ff624f
Show file tree
Hide file tree
Showing 2 changed files with 365 additions and 43 deletions.
186 changes: 146 additions & 40 deletions src/main/cpp/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,152 @@ void Logger::warn(const std::basic_string<UniChar>& msg) const

#endif


#if LOG4CXX_CFSTRING_API
void Logger::forcedLog(const LevelPtr& level, const CFStringRef& message,
const LocationInfo& location) const
{
if (!getHierarchy()) // Has removeHierarchy() been called?
return;
Pool p;
LOG4CXX_DECODE_CFSTRING(msg, message);
auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(msg));
callAppenders(event, p);
}

void Logger::forcedLog(const LevelPtr& level, const CFStringRef& message) const
{
if (!getHierarchy()) // Has removeHierarchy() been called?
return;
Pool p;
LOG4CXX_DECODE_CFSTRING(msg, message);
auto event = std::make_shared<LoggingEvent>(m_priv->name, level, msg,
LocationInfo::getLocationUnavailable());
callAppenders(event, p);
}

void Logger::getName(CFStringRef& rv) const
{
rv = Transcoder::encode(m_priv->name);
}

LoggerPtr Logger::getLogger(const CFStringRef& name)
{
return LogManager::getLogger(name);
}

void Logger::trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
if (isTraceEnabled())
{
forcedLog(log4cxx::Level::getTrace(), msg, location);
}
}
void Logger::trace(const CFStringRef& msg) const
{
if (isTraceEnabled())
{
forcedLog(log4cxx::Level::getTrace(), msg);
}
}

void Logger::debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
if (isDebugEnabled())
{
forcedLog(log4cxx::Level::getDebug(), msg, location);
}
}
void Logger::debug(const CFStringRef& msg) const
{
if (isDebugEnabled())
{
forcedLog(log4cxx::Level::getDebug(), msg);
}
}

void Logger::error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
if (isErrorEnabled())
{
forcedLog(log4cxx::Level::getError(), msg, location);
}
}

void Logger::error(const CFStringRef& msg) const
{
if (isErrorEnabled())
{
forcedLog(log4cxx::Level::getError(), msg);
}
}

void Logger::fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
if (isFatalEnabled())
{
forcedLog(log4cxx::Level::getFatal(), msg, location);
}
}

void Logger::fatal(const CFStringRef& msg) const
{
if (isFatalEnabled())
{
forcedLog(log4cxx::Level::getFatal(), msg);
}
}

void Logger::info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
if (isInfoEnabled())
{
forcedLog(log4cxx::Level::getInfo(), msg, location);
}
}

void Logger::info(const CFStringRef& msg) const
{
if (isInfoEnabled())
{
forcedLog(log4cxx::Level::getInfo(), msg);
}
}

void Logger::log(const LevelPtr& level1, const CFStringRef& message,
const log4cxx::spi::LocationInfo& location) const
{
if (isEnabledFor(level1))
{
forcedLog(level1, message, location);
}
}

void Logger::log(const LevelPtr& level1, const CFStringRef& message) const
{
if (isEnabledFor(level1))
{
forcedLog(level1, message);
}
}

void Logger::warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
if (isWarnEnabled())
{
forcedLog(log4cxx::Level::getWarn(), msg, location);
}
}

void Logger::warn(const CFStringRef& msg) const
{
if (isWarnEnabled())
{
forcedLog(log4cxx::Level::getWarn(), msg);
}
}
#endif

#if LOG4CXX_QSTRING_API
void Logger::addEvent(const LevelPtr& level, QString&& message, const LocationInfo& location) const
{
Expand Down Expand Up @@ -1126,44 +1272,4 @@ void Logger::qwarn(const QString& msg, const spi::LocationInfo& location) const
}
#endif

#if LOG4CXX_CFSTRING_API
void Logger::forcedLog(const LevelPtr& level, const CFStringRef& message,
const LocationInfo& location) const
{
if (!getHierarchy()) // Has removeHierarchy() been called?
return;
Pool p;
LOG4CXX_DECODE_CFSTRING(msg, message);
auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(msg));
callAppenders(event, p);
}

void Logger::forcedLog(const LevelPtr& level, const CFStringRef& message) const
{
if (!getHierarchy()) // Has removeHierarchy() been called?
return;
Pool p;
LOG4CXX_DECODE_CFSTRING(msg, message);
auto event = std::make_shared<LoggingEvent>(m_priv->name, level, msg,
LocationInfo::getLocationUnavailable());
callAppenders(event, p);
}

void Logger::getName(CFStringRef& rv) const
{
rv = Transcoder::encode(m_priv->name);
}

LoggerPtr Logger::getLogger(const CFStringRef& name)
{
return LogManager::getLogger(name);
}

void Logger::trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
rv = Transcoder::encode(m_priv->name);
}
#endif



Loading

0 comments on commit 7ff624f

Please sign in to comment.