You are not logged in.
Pages: 1
Hi to all,
I'm new here and to mORMot also Yesterday I looked up the possibilities to create file based logging and found SynLog.pas.
I'm using the nightly build from yesterday, Delphi is XE5. But two small things I didn't get running.
1.) If I want to log a TPersistent object always "info null" written to the log file
TTest = class(TPersistent)
private
FVorname: SynUnicode;
FNachname: SynUnicode;
FPLZ: integer;
published
property Vorname: SynUnicode read FVorname write FVorname;
property Nachname: SynUnicode read FNachname write FNachname;
property PLZ: integer read FPLZ write FPLZ;
end;
..
var
test: TTest;
begin
test := TTest.Create;
try
test.Vorname := 'Carsten';
TSynLog.Add.Log(sllInfo, test);
finally
test.Free;
end;
// Part where it is produced is SynCommons.pas, line about 34486
// Last part always true and nil is assigned
// didn't it work with TPersistent and published properties??
procedure TTextWriter.WriteObject(Value: TObject; Options: TTextWriterWriteObjectOptions);
...
if not(woFullExpand in Options) or
not (Value.InheritsFrom(TList)
{$ifndef LVCL} or Value.InheritsFrom(TCollection){$endif}) then
Value := nil;
...
How could I write an object content in json notation? Didn't find an automatic call to WriteObjectAsString to serialize objects to json.
2.) Debug console doesn't work for me, as descriped in this thread. As written I'm using the nighly build with the discribed changes included
http://synopse.info/forum/viewtopic.php?id=2419
I used exact the same example, nothing appears in Debug/Messages window, if I use OutputDebugString instead it works.
Because many more people will use logging, my thought is that something is missing or misconfigurated in my environment.
I only use SynCommons.pas, SynLog.pas, Synapse.inc (without modification), SynLz.pas and SynZip.pas + the two .obj files for packing logs into zip files. But packing can't be the problem, both problems occurring in flat file logging.
Thanks for your time to read and any hint
Excalibur (Carsten)
Offline
To allow class serialization, you need to use TSQLLog as defined in mORMot.pas, and not the TSynLog class.
I just checked the test program of http://synopse.info/forum/viewtopic.php?id=2419 and for me it works as expected.
The information is meant to be logged in the console, not in the IDE Debug/Message window.
It is as designed. If you want to log to the IDE Debug/Message windows, use TSynLog.DebuggerNotify().
Offline
Hello,
many thanks for this informations, bringing me on track So I will use the internal delphi owned json routines an pass the argument as log string. Did you see a chance to log objects with serialization also in flat text files in a future version or mORMot?
I tried out and see the difference in output going to Console and Debug console - my error in understanding. Sorry about that. DebuggerNotify works fine and as I need, console output also!
Happy (white?) Easter days
Excalibur (Carsten)
Last edited by Excalibur (2015-04-02 08:51:05)
Offline
The internal Delphi owned JSON routines are much less powerful than the one included in mORMot.pas, and will consume more memory and CPU - especially when log is disabled.
If you use TSQLLog, you will be able to log objects with serialization!
Happy Easter to you too!
Offline
Pages: 1