mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Plugin API: Add RmLog and RmLogF functions
These functions take a `void* rm` parameter that is used to populate the Source field in the log.
This commit is contained in:
parent
f99418dd2d
commit
c2530b3761
@ -117,19 +117,48 @@ void __stdcall RmExecute(void* skin, LPCWSTR command)
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LSLog(int nLevel, LPCWSTR unused, LPCWSTR pszMessage)
|
||||
BOOL LSLog(int level, LPCWSTR unused, LPCWSTR message)
|
||||
{
|
||||
NULLCHECK(pszMessage);
|
||||
NULLCHECK(message);
|
||||
|
||||
// Ignore Level::Debug messages from plugins unless in debug mode
|
||||
if (nLevel != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
|
||||
// Ignore Debug messages from plugins unless in debug mode.
|
||||
if (level != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
|
||||
{
|
||||
GetLogger().Log((Logger::Level)nLevel, L"", pszMessage);
|
||||
GetLogger().Log((Logger::Level)level, L"", message);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void __stdcall RmLog(void* rm, int level, LPCWSTR message)
|
||||
{
|
||||
NULLCHECK(message);
|
||||
|
||||
MeasurePlugin* measure = (MeasurePlugin*)rm;
|
||||
|
||||
// Ignore Debug messages from plugins unless in debug mode.
|
||||
if (level != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
|
||||
{
|
||||
GetLogger().LogSection((Logger::Level)level, measure, message);
|
||||
}
|
||||
}
|
||||
|
||||
void RmLogF(void* rm, int level, LPCWSTR format, ...)
|
||||
{
|
||||
NULLCHECK(format);
|
||||
|
||||
MeasurePlugin* measure = (MeasurePlugin*)rm;
|
||||
|
||||
// Ignore Debug messages from plugins unless in debug mode.
|
||||
if (level != (int)Logger::Level::Debug || GetRainmeter().GetDebug())
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
GetLogger().LogSectionVF((Logger::Level)level, measure, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
// Deprecated!
|
||||
LPCWSTR ReadConfigString(LPCWSTR section, LPCWSTR option, LPCWSTR defValue)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
LIBRARY
|
||||
EXPORTS
|
||||
; Note: If new functions are added, the Rainmeter.lib files in Plugins\API\x32 and Plugins\API\x64
|
||||
; must be replaced by the corresponding file in Library\x32\Release and Library\x64\Release.
|
||||
; Note: If new functions are added, the Rainmeter.lib files in Plugins\API\{x32,x64} must be
|
||||
; replaced by the corresponding file in {x32,x64}-Release\Obj\Library.
|
||||
; Set '<ExcludeTests>true</ExcludeTests>' in Rainmeter.props first to minimize the .lib size.
|
||||
RmReadString
|
||||
RmReadFormula
|
||||
@ -9,6 +9,8 @@ EXPORTS
|
||||
RmPathToAbsolute
|
||||
RmExecute
|
||||
RmGet
|
||||
RmLog
|
||||
RmLogF
|
||||
LSLog
|
||||
ReadConfigString
|
||||
PluginBridge
|
||||
|
@ -234,7 +234,7 @@ void Logger::LogVF(Level level, const WCHAR* source, const WCHAR* format, va_lis
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
void Logger::LogSectionVF(Logger::Level level, Section* section, const WCHAR* format, va_list args)
|
||||
std::wstring GetSectionSourceString(Section* section)
|
||||
{
|
||||
std::wstring source;
|
||||
if (section)
|
||||
@ -250,7 +250,18 @@ void Logger::LogSectionVF(Logger::Level level, Section* section, const WCHAR* fo
|
||||
source += section->GetOriginalName();
|
||||
source += L']';
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
void Logger::LogSection(Logger::Level level, Section* section, const WCHAR* message)
|
||||
{
|
||||
const std::wstring source = GetSectionSourceString(section);
|
||||
GetLogger().Log(level, source.c_str(), message);
|
||||
}
|
||||
|
||||
void Logger::LogSectionVF(Logger::Level level, Section* section, const WCHAR* format, va_list args)
|
||||
{
|
||||
const std::wstring source = GetSectionSourceString(section);
|
||||
GetLogger().LogVF(level, source.c_str(), format, args);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
void Log(Level level, const WCHAR* source, const WCHAR* msg);
|
||||
void LogVF(Level level, const WCHAR* source, const WCHAR* format, va_list args);
|
||||
void LogMeterWindowVF(Logger::Level level, MeterWindow* meterWindow, const WCHAR* format, va_list args);
|
||||
void LogSection(Logger::Level level, Section* section, const WCHAR* message);
|
||||
void LogSectionVF(Logger::Level level, Section* section, const WCHAR* format, va_list args);
|
||||
|
||||
const std::wstring& GetLogFilePath() { return m_LogFilePath; }
|
||||
|
@ -55,7 +55,9 @@ protected:
|
||||
|
||||
bool UpdateCounter();
|
||||
|
||||
const std::wstring m_Name; // Name of this Section
|
||||
// Plugins may access this string through RmGetMeasureName(). This should never changed be to
|
||||
// ensure thread-safety.
|
||||
const std::wstring m_Name;
|
||||
|
||||
bool m_DynamicVariables; // If true, the section contains dynamic variables
|
||||
int m_UpdateDivider; // Divider for the update
|
||||
|
@ -56,7 +56,11 @@ enum RmGetType
|
||||
RMG_SKINWINDOWHANDLE = 4
|
||||
};
|
||||
|
||||
LIBRARY_EXPORT BOOL LSLog(int type, LPCWSTR unused, LPCWSTR message);
|
||||
LIBRARY_EXPORT void __stdcall RmLog(void* rm, int level, LPCWSTR message);
|
||||
|
||||
LIBRARY_EXPORT void __cdecl RmLogF(void* rm, int level, LPCWSTR format, ...);
|
||||
|
||||
LIBRARY_EXPORT BOOL __cdecl LSLog(int level, LPCWSTR unused, LPCWSTR message);
|
||||
|
||||
//
|
||||
// Wrapper functions
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user