Made log messages more consistent.

This commit is contained in:
Birunthan Mohanathas 2011-11-09 09:27:06 +00:00
parent f8f31a527e
commit 1e9d424c99
16 changed files with 55 additions and 60 deletions

View File

@ -744,9 +744,9 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
error += ConvertToWide(errMsg); error += ConvertToWide(errMsg);
error += L" in key \""; error += L" in key \"";
error += key ? key : L""; error += key ? key : L"";
error += L"\" in section ["; error += L"\" in [";
error += section ? section : L""; error += section ? section : L"";
error += L"]."; error += L"]";
Log(LOG_ERROR, error.c_str()); Log(LOG_ERROR, error.c_str());
} }

View File

@ -25,17 +25,13 @@
class CError class CError
{ {
public: public:
CError(const std::wstring& String) : m_String(String), m_File(NULL) {} CError(const std::wstring& String) : m_String(String) {}
CError(const WCHAR* String ) : m_String(String), m_File(NULL) {} CError(const WCHAR* String ) : m_String(String) {}
CError(const std::wstring& String, int Line, const char* File) : m_String(String), m_Line(Line), m_File(File) {}
CError(const WCHAR* String, int Line, const char* File) : m_String(String), m_Line(Line), m_File(File) {}
const std::wstring& GetString(); const std::wstring& GetString();
private: private:
std::wstring m_String; std::wstring m_String;
int m_Line;
const char* m_File;
}; };
#endif #endif

View File

@ -836,7 +836,7 @@ CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, cons
error += L" is not valid in ["; error += L" is not valid in [";
error += name; error += name;
error += L"]"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
return NULL; return NULL;
} }

View File

@ -84,9 +84,9 @@ bool CMeasureCalc::Update()
{ {
std::wstring error = L"Calc: "; std::wstring error = L"Calc: ";
error += ConvertToWide(errMsg); error += ConvertToWide(errMsg);
error += L" in measure ["; error += L" in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
Log(LOG_ERROR, error.c_str()); Log(LOG_ERROR, error.c_str());
} }

View File

@ -151,7 +151,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
std::wstring error = L"Plugin: \"" + m_PluginName; std::wstring error = L"Plugin: \"" + m_PluginName;
error += L"\" not found"; error += L"\" not found";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }
@ -167,8 +167,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
FreeLibrary(m_Plugin); FreeLibrary(m_Plugin);
std::wstring error = L"Plugin: \"" + m_PluginName; std::wstring error = L"Plugin: \"" + m_PluginName;
error += L"\" doesn't export Update() or GetString()!"; error += L"\" doesn't export Update() or GetString()";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
// Initialize the plugin // Initialize the plugin

View File

@ -154,7 +154,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
error += L" is not valid in ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
m_RegKeyName = parser.ReadString(section, L"RegKey", L""); m_RegKeyName = parser.ReadString(section, L"RegKey", L"");

View File

@ -462,8 +462,8 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
if (m_MeasureName.empty()) if (m_MeasureName.empty())
{ {
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] is unbound!"; error += L"] is unbound";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
// Go through the list and check it there is a measure for us // Go through the list and check it there is a measure for us
@ -481,8 +481,8 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += m_MeasureName; error += m_MeasureName;
error += L"]!"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
/* /*
@ -534,10 +534,10 @@ CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHA
// Error // Error
std::wstring error = L"Meter="; std::wstring error = L"Meter=";
error += meter; error += meter;
error += L" is not valid in section ["; error += L" is not valid in [";
error += name; error += name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
return NULL; return NULL;
} }

View File

@ -131,10 +131,10 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section)
else else
{ {
std::wstring error = L"BarOrientation=" + orientation; std::wstring error = L"BarOrientation=" + orientation;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
if (m_Initialized) if (m_Initialized)

View File

@ -212,10 +212,10 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section)
else else
{ {
std::wstring error = L"BitmapAlign=" + align; std::wstring error = L"BitmapAlign=" + align;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
if (m_Initialized) if (m_Initialized)

View File

@ -529,7 +529,7 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += m_SecondaryMeasureName; error += m_SecondaryMeasureName;
error += L"]!"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }

View File

@ -388,8 +388,8 @@ void CMeterImage::BindMeasure(const std::list<CMeasure*>& measures)
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += (*j); error += (*j);
error += L"]!"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }
CMeter::SetAllMeasures(m_Measures); CMeter::SetAllMeasures(m_Measures);

View File

@ -377,8 +377,8 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += (*j); error += (*j);
error += L"]!"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }
CMeter::SetAllMeasures(m_Measures); CMeter::SetAllMeasures(m_Measures);

View File

@ -279,7 +279,7 @@ void CMeterString::Initialize()
if (m_FontSize != 0) if (m_FontSize != 0)
{ {
std::wstring error = L"String: Unable to create font: " + m_FontFace; std::wstring error = L"String: Unable to create font: " + m_FontFace;
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }
} }
@ -378,10 +378,10 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
else else
{ {
std::wstring error = L"StringAlign=" + align; std::wstring error = L"StringAlign=" + align;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE"); const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE");
@ -404,10 +404,10 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
else else
{ {
std::wstring error = L"StringCase=" + stringCase; std::wstring error = L"StringCase=" + stringCase;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL"); const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL");
@ -430,10 +430,10 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
else else
{ {
std::wstring error = L"StringStyle=" + style; std::wstring error = L"StringStyle=" + style;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE"); const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE");
@ -452,10 +452,10 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
else else
{ {
std::wstring error = L"StringEffect=" + effect; std::wstring error = L"StringEffect=" + effect;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += m_Name; error += m_Name;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
if (m_Initialized && if (m_Initialized &&
@ -697,8 +697,8 @@ void CMeterString::BindMeasure(const std::list<CMeasure*>& measures)
std::wstring error = L"The meter [" + m_Name; std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with ["; error += L"] cannot be bound with [";
error += (*j); error += (*j);
error += L"]!"; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }
CMeter::SetAllMeasures(m_Measures); CMeter::SetAllMeasures(m_Measures);

View File

@ -255,7 +255,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
if (err != 0 && ERROR_CLASS_ALREADY_EXISTS != err) if (err != 0 && ERROR_CLASS_ALREADY_EXISTS != err)
{ {
throw CError(L"Unable to register class!", __LINE__, __FILE__); throw CError(L"Unable to register class");
} }
} }
@ -274,7 +274,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
if (m_Window == NULL) if (m_Window == NULL)
{ {
throw CError(L"Unable to register window!", __LINE__, __FILE__); throw CError(L"Unable to register window");
} }
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
@ -441,13 +441,13 @@ void CMeterWindow::Refresh(bool init, bool all)
{ {
if (0 == SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL)) if (0 == SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL))
{ {
throw CError(L"Unable to set timer!", __LINE__, __FILE__); throw CError(L"Unable to set timer");
} }
} }
if (0 == SetTimer(m_Window, TIMER_MOUSE, INTERVAL_MOUSE, NULL)) // Mouse position is checked twice per sec if (0 == SetTimer(m_Window, TIMER_MOUSE, INTERVAL_MOUSE, NULL)) // Mouse position is checked twice per sec
{ {
throw CError(L"Unable to set timer!", __LINE__, __FILE__); throw CError(L"Unable to set timer");
} }
m_Rainmeter->SetCurrentParser(NULL); m_Rainmeter->SetCurrentParser(NULL);

View File

@ -626,10 +626,10 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::wstring error = m_ConfigArray[ConfigIndexImageCrop]; std::wstring error = m_ConfigArray[ConfigIndexImageCrop];
error += L"="; error += L"=";
error += crop; error += crop;
error += L" (origin) is not valid in meter ["; error += L" (origin) is not valid in [";
error += section; error += section;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
} }
} }
@ -734,10 +734,10 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::wstring error = m_ConfigArray[ConfigIndexImageFlip]; std::wstring error = m_ConfigArray[ConfigIndexImageFlip];
error += L"="; error += L"=";
error += flip; error += flip;
error += L" is not valid in meter ["; error += L" is not valid in [";
error += section; error += section;
error += L"]."; error += L"]";
throw CError(error, __LINE__, __FILE__); throw CError(error);
} }
if (!m_DisableTransform) if (!m_DisableTransform)

View File

@ -100,7 +100,6 @@ static int MeterWindow_GetMeter(lua_State* L)
{ {
std::wstring error = L"Script: No such meter as "; std::wstring error = L"Script: No such meter as ";
error += meterName; error += meterName;
error += L".";
Log(LOG_ERROR, error.c_str()); Log(LOG_ERROR, error.c_str());
return 0; return 0;
} }