#1 2017-11-10 16:45:25

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

Since normally the console color is black, could you consider to reset color to ccBlack instead of ccLightGray at the end of TSynLog.ConsoleEcho ?
Currently, if EchoToConsole is set to LOG_VERBOSE, the color of the prompt for the next command becomes from black to light gray, which seems odd... big_smile

Example:

program Project1;

{$IFNDEF FPC}
{$APP CONSOLE}
{$ENDIF}

uses
  SysUtils,
  SynCommons, SynLog;

procedure xx;
var
 ILog: ISynLog;
 SMethodName: string;
 SMethodNameUTF8: RawUTF8;
begin
  SMethodName := 'enter xx';
  SMethodNameUTF8 := StringToUTF8(SMethodName);
  (*
    [url]https://synopse.info/forum/viewtopic.php?pid=25540[/url]
    @ returns a pointer to a variable: @str is a pointer to the string pointer, not to the string content
    @str[1] is a pointer to the first char, i.e., the pointer to the string content
    Pointer() type-cast the variable to another type: hard-cast of a string variable as Pointer returns the pointer to the string content
  *)
  // Does not work.
  // ILog := TSynLog.Enter(nil, @SMethodNameUTF8);
  // Either way works.
  ILog := TSynLog.Enter(nil, @SMethodNameUTF8[1]);
  // ILog := TSynLog.Enter(nil, Pointer(SMethodNameUTF8));
  ILog.Log(sllWarning, 'hi xx');
end;

begin
  with TSynLog.Family do
  begin
    {$IFDEF MSWINDOWS}
      AutoFlushTimeOut := 1;
    {$ENDIF ~MSWINDOWS}
    Level := LOG_VERBOSE;
    EchoToConsole := LOG_VERBOSE;
    PerThreadLog := ptIdentifiedInOnFile;
    RotateFileCount := 50;
    RotateFileSizeKB := 20 * 1024; // rotate by 20 MB logs
  end;

  xx;
end.

rh4c5i.png

Last edited by ComingNine (2017-11-10 16:46:06)

Offline

#2 2017-11-10 17:27:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,669
Website

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

This is the default under Windows...

Under Linux, is it always a black color?

Offline

#3 2017-11-11 11:15:34

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

After searching the internet I am still not sure. For example, on some distributions the default terminal color is dependent on the "theme". Perhaps it is better to leave it as is...

Offline

#4 2017-11-12 08:26:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,669
Website

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

Offline

#5 2017-11-12 11:10:43

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

Many thanks for your effort ! I will insert "Crt.NormVideo" at the end of .lpr under FPC smile

Offline

#6 2017-11-12 11:13:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,669
Website

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

After checking the source, sounds like if NormVideo is just a void procedure!!!!
sad

Offline

#7 2017-11-12 13:10:02

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

It seems NormVideo is not void ?

Procedure NormVideo;
{
  Set normal back and foregroundcolors.
}
Begin
  TextColor(7);
  TextBackGround(0);
End; 

yikes I just tried to add "Crt.NormVideo" at the end of the above .lpr under FPC and it worked.

Offline

#8 2017-11-12 13:45:41

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Reset color to ccBlack instead of ccLightGray in TSynLog.ConsoleEcho ?

yikes Sorry. It seems that linking the Crt unit will drastically change how SynLog colorize the echoed log. For example, sllInfo level log will be bold instead of being ccWhite.

For me, it looks more natural to reset color to ccBlack instead of ccLightGray at the end of TSynLog.ConsoleEcho with Linux.

Offline

Board footer

Powered by FluxBB