You are not logged in.
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...
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.
Last edited by ComingNine (2017-11-10 16:46:06)
Offline
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
Under FPC, we could just call https://www.freepascal.org/docs-html/rt … video.html
Offline
Many thanks for your effort ! I will insert "Crt.NormVideo" at the end of .lpr under FPC
Offline
It seems NormVideo is not void ?
Procedure NormVideo;
{
Set normal back and foregroundcolors.
}
Begin
TextColor(7);
TextBackGround(0);
End;
I just tried to add "Crt.NormVideo" at the end of the above .lpr under FPC and it worked.
Offline
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