#1 2025-05-13 08:26:21

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 555

Simple Question for new DoLog/Enter

Hi Arnaud i have a may be stupid question how to handle your Change in TSynLog.DoLog/Enter in our Programs

you changed one Parameter from RawUtf8 to PUtf8Char

what is the best way to fix the Compiler Errors:

Sample 1:

old:
var XYZ: String := 'test'; // Sometimes we got String Var
TSynLog.Enter(StringToUtf8(XYZ), ...);
new:
TSynLog.Enter(PUtf8Char(StringToUtf8(XYZ)), ...);  // is this the best way ?

Im not sure what this cast really does smile


Rad Studio 12.3 Athens / 13.0 Ganymede

Offline

#2 2025-05-13 10:26:05

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 391

Re: Simple Question for new DoLog/Enter

The best way is not to use TSynLog.Enter(...
Instead use:

var
  aLog: ISynLog;
begin
  aLog:= TSynLog.Enter(Self); //this is the first line before any other log
  aLog.Log(sslInfo, ...

Offline

#3 2025-05-15 09:19:17

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 555

Re: Simple Question for new DoLog/Enter

TY Daniel, this makes sense if you like to add something else to the Log.
My Question was concerning the Use of the Cast to PUtf8Char


Rad Studio 12.3 Athens / 13.0 Ganymede

Offline

#4 2025-05-15 11:10:51

tbo
Member
Registered: 2015-04-20
Posts: 364

Re: Simple Question for new DoLog/Enter

itSDS wrote:

My Question was concerning the Use of the Cast to PUtf8Char

Defined as: "class function TSynLog.Enter(const TextFmt: RawUtf8; ...", then "TSynLog.Enter(StringToUtf8(XYZ), ...".
Defined as: "class function TSynLog.Enter(const TextFmt: PUtf8Char; ...", then "TSynLog.Enter(PUtf8Char(StringToUtf8(XYZ)), ..." or "TSynLog.Enter(Pointer(StringToUtf8(XYZ)), ...".

With best regards
Thomas

Last edited by tbo (2025-05-15 11:30:19)

Offline

#5 2025-05-28 13:06:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,069
Website

Re: Simple Question for new DoLog/Enter

Consider the new TSynLog.EnterLocal() methods instead of plain Enter(), if you make a code review.

And the very new EnterLocalString() which don't involve formatUtF8() but could be used for a generic string value:
https://github.com/synopse/mORMot2/commit/04cd30a0f

Offline

Board footer

Powered by FluxBB