#1 2013-03-04 20:26:07

morto
Member
Registered: 2013-03-04
Posts: 2

Is there a TSynLog tutorial or sample code ?

I was looking for a Delphi logging framework and found TSynLog.
However I could not find any documentation, tutorial or sample code.

I tried to search the forum and googled it but could not find anything remotely close to what I was looking for.

Could you please point me to some documentation or provide a 'get started' sample code ?

Thank you for your attention.

Offline

#2 2013-03-05 07:38:01

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

Re: Is there a TSynLog tutorial or sample code ?

For some sample code, see "11 - Exception logging" folder in "Sqlite3\Samples".

Then download the SAD pdf (preferred latest 1.18 revision), and read the "Logging" information (in "Testing and logging" chapter).

Offline

#3 2013-03-05 22:01:01

morto
Member
Registered: 2013-03-04
Posts: 2

Re: Is there a TSynLog tutorial or sample code ?

Thank you very much for your reply.

May I suggest to include one important piece of information in the sample code and documentation that I only found in the source code SynCommons.pas:

  // - you should create a sub class per kind of log file.

It took me a while to get it working, until I read that.

It could be shown in the sample code the Family.Level being set.
  Family.Level := [sllException,sllExceptionOS, sllInfo, sllDebug, sllTrace,
                   sllWarning, sllError, sllEnter, sllLeave, sllLastError,
                   sllLastError, sllMemory, sllStackTrace, sllFail];

Also it would be nice to inform (this is Delphi info, not framework, but it would be convenient to have the information there) how to get the .map file generated with some text like this:
"you must ensure the {D+} compiler directive is set, and the "Detailed Map File" option selected in the Project >Options>Linker page of the IDE"

Thanks again,
Mau.

Offline

#4 2013-03-06 07:33:24

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

Re: Is there a TSynLog tutorial or sample code ?

You are right, we found the per-class instance to be a "feature" at first, then realized it was some kind of bulky singleton pattern, which I do not like at all.
I've created a feature request to enhance the documentation and samples about this. See http://synopse.info/fossil/info/d3f5197f3c
In fact, you can create your own TSynLogFamily instance, with appropriate settings, then inject it at the constructor level:

constructor TSynLog.Create(aFamily: TSynLogFamily);

What is wrong with Family.level := LOG_VERBOSE ?
I think I may have mislead you in the SAD pdf. There is the "Enhanced logging" under the "SynCommons unit" chapter, which is much more complete than the "Logging" information (in "Testing and logging" chapter).
You may have found much more info here, including a list of Family.Level values.*
Sorry for the misinformation. wink

I've also updated the documentation, according to your feedback.
See http://synopse.info/fossil/info/66261c9e2e
Thanks!

Offline

Board footer

Powered by FluxBB