Closed yanlusu closed 1 year ago
One of the solutions is to create several logger instances (if you know module names at compile time):
Thus you can control severity and turn on/off log messages per module name. Then you need to create a new formatter class and specify there a new field:
ss << PLOG_NSTR("[") << instanceIdToString(record.getInstanceId()) << PLOG_NSTR("] ");
and implement instanceIdToString
. It could look like this:
inline const char* instanceIdToString(int instanceId)
{
switch (instanceId)
{
case Auth:
return "Auth;
case FileIO:
return "FileIO";
default:
return "Default";
}
}
One of the solutions is to create several logger instances (if you know module names at compile time):
Thus you can control severity and turn on/off log messages per module name. Then you need to create a new formatter class and specify there a new field:
ss << PLOG_NSTR("[") << instanceIdToString(record.getInstanceId()) << PLOG_NSTR("] ");
and implement
instanceIdToString
. It could look like this:inline const char* instanceIdToString(int instanceId) { switch (instanceId) { case Auth: return "Auth; case FileIO: return "FileIO"; default: return "Default"; } }
good idea, thank you.
How to add custom prefix (record) information?
Just like:
and I don't want to add to every PLOG statement. what I want maybe like this:
I know I can use macro to implement it, but it's not good, and I cannot use other feature such as condition log;
Is there a general solution to this?
thanks.