LazLogger ignores the first entry of the param that deals with enabled/disabled log groups
- Lazarus/FPC Version: 2.0.12
- Operating System: Ubuntu 21.10
- CPU / Bitness: 64bits
What happens
LazLogger
ignores the first item of the comma separated list passed to the param that deals with enabled/disbled log groups
Example source
program LazLoggerCLI;
// Remember to add LCL to the needed packages of the project
{$mode objfpc}{$H+}
uses
LazLogger
;
var
LOG_INFO,
LOG_WARNING,
LOG_ERROR,
LOG_DEBUG: PLazLoggerLogGroup;
begin
// Initializing Log Groups
DebugLogger.ParamForEnabledLogGroups:= '--debug-enable';
LOG_INFO:=DebugLogger.FindOrRegisterLogGroup('LOG_INFO', True);
LOG_WARNING:=DebugLogger.FindOrRegisterLogGroup('LOG_WARNING', True);
LOG_ERROR:=DebugLogger.FindOrRegisterLogGroup('LOG_ERROR', True);
LOG_DEBUG:=DebugLogger.FindOrRegisterLogGroup('LOG_DEBUG', False);
DebugLn('Starting');
DebugLn('LogName: ', DebugLogger.LogName);
DebugLn('ParamForEnabledLogGroups: ', DebugLogger.ParamForEnabledLogGroups);
DebugLnEnter('Start doing some work');
DebugLn(LOG_INFO, 'LOG_INFO: I''m happy doing work!');
DebugLn(LOG_WARNING, 'LOG_WARNING: I''m happy doing work!');
DebugLn(LOG_ERROR, 'LOG_ERROR: I''m happy doing work!');
DebugLn(LOG_DEBUG, 'LOG_DEBUG: I''m happy doing work!');
DebugLn('DEBUGLN: I''m happy doing work!');
DbgOut('DBGOUT: I''m happy doing work!');
DebugLnExit('Ending doing some work');
DebugLn('Ending');
end.
What did you expect
When calling the program this way:
$ lazloggercli --debug-enable=LOG_DEBUG
I get this output:
Starting
LogName:
ParamForEnabledLogGroups: --debug-enable
Start doing some work
LOG_INFO: I'm happy doing work!
LOG_WARNING: I'm happy doing work!
LOG_ERROR: I'm happy doing work!
DEBUGLN: I'm happy doing work!
DBGOUT: I'm happy doing work!
Ending doing some work
Ending
But if I add a comma before the log group, technically having an empty first element:
$ lazloggercli --debug-enable=,LOG_DEBUG
Then I get the desired output:
Starting
LogName:
ParamForEnabledLogGroups: --debug-enable
Start doing some work
LOG_INFO: I'm happy doing work!
LOG_WARNING: I'm happy doing work!
LOG_ERROR: I'm happy doing work!
LOG_DEBUG: I'm happy doing work!
DEBUGLN: I'm happy doing work!
DBGOUT: I'm happy doing work!
Ending doing some work
Ending
Steps to reproduce
Has stated above