Skip to content

Commit

Permalink
Better visibility for WARNINGS in Console logger
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed May 16, 2024
1 parent 1a10545 commit 4c5441d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
44 changes: 23 additions & 21 deletions ideexpert/DMVC.Expert.CodeGen.Commands.pas
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,30 @@ procedure TUnitMainBeginEndCommand.ExecuteImplementation(Section: TStringBuilder
.AppendLine(' // When MVCSerializeNulls = True empty nullables and nil are serialized as json null.')
.AppendLine(' // When MVCSerializeNulls = False empty nullables and nil are not serialized at all.')
.AppendLine(' MVCSerializeNulls := True;')
.AppendLine(' UseConsoleLogger := True;');
.AppendLine(' UseConsoleLogger := True;')
.AppendLine
.AppendLine(' LogI(''** DMVCFramework Server ** build '' + DMVCFRAMEWORK_VERSION);');

if Model.B[TConfigKey.program_dotenv] then
begin
Section
.AppendLine
.AppendLine(' dotEnvConfigure(')
.AppendLine(' function: IMVCDotEnv')
.AppendLine(' begin')
.AppendLine(' Result := NewDotEnv')
.AppendLine(' .UseStrategy(TMVCDotEnvPriority.FileThenEnv)')
.AppendLine(' //if available, by default, loads default environment (.env)')
.AppendLine(' .UseProfile(''test'') //if available loads the test environment (.env.test)')
.AppendLine(' .UseProfile(''prod'') //if available loads the prod environment (.env.prod)')
.AppendLine(' .UseLogger(procedure(LogItem: String)')
.AppendLine(' begin')
.AppendLine(' LogD(''dotEnv: '' + LogItem);')
.AppendLine(' end)')
.AppendLine(' .Build(); //uses the executable folder to look for .env* files')
.AppendLine(' end);')
.AppendLine;
end;

if Model.B[TConfigKey.program_sqids] then
begin
Expand All @@ -1010,30 +1032,10 @@ procedure TUnitMainBeginEndCommand.ExecuteImplementation(Section: TStringBuilder

Section
.AppendLine
.AppendLine(' LogI(''** DMVCFramework Server ** build '' + DMVCFRAMEWORK_VERSION);')
.AppendLine(' try')
.AppendLine(' if WebRequestHandler <> nil then')
.AppendLine(' WebRequestHandler.WebModuleClass := WebModuleClass;')
.AppendLine;
if Model.B[TConfigKey.program_dotenv] then
begin
Section
.AppendLine(' dotEnvConfigure(')
.AppendLine(' function: IMVCDotEnv')
.AppendLine(' begin')
.AppendLine(' Result := NewDotEnv')
.AppendLine(' .UseStrategy(TMVCDotEnvPriority.FileThenEnv)')
.AppendLine(' //if available, by default, loads default environment (.env)')
.AppendLine(' .UseProfile(''test'') //if available loads the test environment (.env.test)')
.AppendLine(' .UseProfile(''prod'') //if available loads the prod environment (.env.prod)')
.AppendLine(' .UseLogger(procedure(LogItem: String)')
.AppendLine(' begin')
.AppendLine(' LogD(''dotEnv: '' + LogItem);')
.AppendLine(' end)')
.AppendLine(' .Build(); //uses the executable folder to look for .env* files')
.AppendLine(' end);')
.AppendLine;
end;
Section
.AppendLine(' WebRequestHandlerProc.MaxConnections := dotEnv.Env(''dmvc.handler.max_connections'', 1024);')
.AppendLine
Expand Down
4 changes: 2 additions & 2 deletions lib/loggerpro/LoggerPro.ConsoleAppender.pas
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ procedure TLoggerProConsoleAppender.Setup;
procedure TLoggerProConsoleAppender.SetupColorMappings;
begin
fColors[TLogType.Debug] := FOREGROUND_GREEN;
fColors[TLogType.Info] := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED;
fColors[TLogType.Warning] := FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_INTENSITY;
fColors[TLogType.Info] := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED or FOREGROUND_INTENSITY;
fColors[TLogType.Warning] := FOREGROUND_RED or FOREGROUND_GREEN;
fColors[TLogType.Error] := FOREGROUND_RED or FOREGROUND_INTENSITY;
fColors[TLogType.Fatal] := FOREGROUND_RED or FOREGROUND_BLUE or FOREGROUND_INTENSITY;
end;
Expand Down
12 changes: 12 additions & 0 deletions unittests/general/Several/BOs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ TMyObject = class
FPropTime: TTime;
FPropCurrency: Currency;
fPropJSONObject: TJSONObject;
FPropIntegerSqids: Integer;
procedure SetPropAnsiString(const Value: AnsiString);
procedure SetPropString(const Value: string);
procedure SetPropInt64(const Value: Int64);
Expand Down Expand Up @@ -455,6 +456,10 @@ TMyObject = class
property PropTimeStamp: TTimeStamp read FPropTimeStamp write SetPropTimeStamp;
property PropCurrency: Currency read FPropCurrency write SetPropCurrency;
property PropJSONObject: TJSONObject read fPropJSONObject;

{sqids}
[MVCSerializeAsSqids]
property PropIntegerSqids: Integer read FPropIntegerSqids write FPropIntegerSqids;
end;

TMyChildObject = class
Expand Down Expand Up @@ -812,6 +817,9 @@ function GetMyObject: TMyObject;
Result.PropJSONObject.O['objprop'].S['innerprop1'] := 'value1';
Result.PropJSONObject.O['objprop'].S['innerprop2'] := 'value2';
Result.PropJSONObject.O['objprop'].S['innerprop3'] := 'value3';

{sqids}
Result.PropIntegerSqids := 1234;
end;

constructor TMyObject.Create;
Expand Down Expand Up @@ -850,6 +858,10 @@ function TMyObject.Equals(Obj: TMyObject): Boolean;
lMyStr := Self.fPropJSONObject.ToJSON();
lOtherStr := Obj.PropJSONObject.ToJSON();
Result := Result and (Self.fPropJSONObject.ToJSON() = Obj.PropJSONObject.ToJSON());


{sqids}
Result := Result and (Self.PropIntegerSqids = Obj.PropIntegerSqids);
end;

procedure TMyObject.SetPropAnsiString(const Value: AnsiString);
Expand Down

0 comments on commit 4c5441d

Please sign in to comment.