mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Implemented boost::format based log proxy.
This commit is contained in:
parent
36c44c2ce7
commit
d6178d0bb5
@ -12,9 +12,57 @@
|
||||
|
||||
namespace vstd
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
void makeFormat(boost::format & fmt, T t)
|
||||
{
|
||||
fmt % t;
|
||||
}
|
||||
|
||||
template <typename T, typename ... Args>
|
||||
void makeFormat(boost::format & fmt, T t, Args ... args)
|
||||
{
|
||||
fmt % t;
|
||||
makeFormat(fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Logger, typename ... Args>
|
||||
void logFormat(Logger * logger, ELogLevel::ELogLevel level, const std::string & format, Args ... args)
|
||||
{
|
||||
boost::format fmt(format);
|
||||
detail::makeFormat(fmt, args...);
|
||||
logger->log(level, fmt.str());
|
||||
}
|
||||
|
||||
template<typename Logger, typename ... Args>
|
||||
void logErrorFormat(Logger * logger, const std::string & format, Args ... args)
|
||||
{
|
||||
logFormat(logger, ELogLevel::ERROR, format, args...);
|
||||
}
|
||||
|
||||
template<typename Logger, typename ... Args>
|
||||
void logWarnFormat(Logger * logger, const std::string & format, Args ... args)
|
||||
{
|
||||
logFormat(logger, ELogLevel::WARN, format, args...);
|
||||
}
|
||||
|
||||
template<typename Logger, typename ... Args>
|
||||
void logInfoFormat(Logger * logger, const std::string & format, Args ... args)
|
||||
{
|
||||
logFormat(logger, ELogLevel::INFO, format, args...);
|
||||
}
|
||||
|
||||
template<typename Logger, typename ... Args>
|
||||
void logDebugFormat(Logger * logger, const std::string & format, Args ... args)
|
||||
{
|
||||
logFormat(logger, ELogLevel::DEBUG, format, args...);
|
||||
}
|
||||
|
||||
template<typename Logger, typename ... Args>
|
||||
void logTraceFormat(Logger * logger, const std::string & format, Args ... args)
|
||||
{
|
||||
logFormat(logger, ELogLevel::TRACE, format, args...);
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
CLoggerStream warnStream() const;
|
||||
CLoggerStream errorStream() const;
|
||||
|
||||
inline void log(ELogLevel::ELogLevel level, const std::string & message) const;
|
||||
void log(ELogLevel::ELogLevel level, const std::string & message) const;
|
||||
|
||||
void addTarget(std::unique_ptr<ILogTarget> && target);
|
||||
void clearTargets();
|
||||
|
@ -129,7 +129,7 @@ const CSpell::LevelInfo & CSpell::getLevelInfo(const int level) const
|
||||
{
|
||||
if(level < 0 || level >= GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
{
|
||||
logGlobal->errorStream() << __FUNCTION__ << " invalid school level " << level;
|
||||
vstd::logErrorFormat(logGlobal, "CSpell::getLevelInfo invalid school level %d", level);
|
||||
throw new std::runtime_error("Invalid school level");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user