mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed CID 1197474, CID 1366358
This commit is contained in:
parent
394d6e0677
commit
36598d8695
@ -51,13 +51,14 @@ namespace vstd
|
||||
virtual ~CLoggerBase(){};
|
||||
|
||||
virtual void log(ELogLevel::ELogLevel level, const std::string & message) const = 0;
|
||||
virtual void log(ELogLevel::ELogLevel level, const boost::format & fmt) const = 0;
|
||||
|
||||
template<typename T, typename ... Args>
|
||||
void log(ELogLevel::ELogLevel level, const std::string & format, T t, Args ... args) const
|
||||
{
|
||||
boost::format fmt(format);
|
||||
makeFormat(fmt, t, args...);
|
||||
log(level, fmt.str());
|
||||
log(level, fmt);
|
||||
}
|
||||
|
||||
/// Log methods for various log levels
|
||||
|
@ -153,6 +153,7 @@
|
||||
<Unit filename="CGameInterface.h" />
|
||||
<Unit filename="CGameState.cpp" />
|
||||
<Unit filename="CGameState.h" />
|
||||
<Unit filename="CGameStateFwd.h" />
|
||||
<Unit filename="CGeneralTextHandler.cpp" />
|
||||
<Unit filename="CGeneralTextHandler.h" />
|
||||
<Unit filename="CHeroHandler.cpp" />
|
||||
|
@ -119,6 +119,18 @@ void CLogger::log(ELogLevel::ELogLevel level, const std::string & message) const
|
||||
callTargets(LogRecord(domain, level, message));
|
||||
}
|
||||
|
||||
void CLogger::log(ELogLevel::ELogLevel level, const boost::format & fmt) const
|
||||
{
|
||||
try
|
||||
{
|
||||
log(level, fmt.str());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log(ELogLevel::ERROR, "Invalid log format!");
|
||||
}
|
||||
}
|
||||
|
||||
ELogLevel::ELogLevel CLogger::getLevel() const
|
||||
{
|
||||
TLockGuard _(mx);
|
||||
|
@ -89,6 +89,7 @@ public:
|
||||
CLoggerStream errorStream() const;
|
||||
|
||||
void log(ELogLevel::ELogLevel level, const std::string & message) const override;
|
||||
void log(ELogLevel::ELogLevel level, const boost::format & fmt) const override;
|
||||
|
||||
void addTarget(std::unique_ptr<ILogTarget> && target);
|
||||
void clearTargets();
|
||||
|
@ -71,6 +71,7 @@
|
||||
</Unit>
|
||||
<Unit filename="StdInc.h">
|
||||
<Option compile="1" />
|
||||
<Option weight="0" />
|
||||
</Unit>
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
|
Loading…
Reference in New Issue
Block a user