Creating and managing category tabs from code

CodeSite logging interface classes: default "CodeSite" logger, T|CodeSiteLogger class, destinations, formatters, etc.

Creating and managing category tabs from code

Postby dcase4688 » Wed Feb 11, 2015 9:06 am

I have a requirement to separate normal application logging and error logging. The easiest way seemed to got with setting the Logger category to "Application" or "error" depending on the type of log event called the send.
This works really well but it looks a little untidy if the users have to enable the auto-organize and set this to use the category.

What I would really like to do is to set these items as part of the logger creation so the user does not have to set these in the actual view. It is much better if these are set as the live view displays.

Is there a way to accomplish this?

Thanks.

By The Way - Loving Codesite!
dcase4688
 
Posts: 1
Joined:
Mon Feb 02, 2015 9:18 am

Re: Creating and managing category tabs from code

Postby Raize Support » Thu Feb 12, 2015 2:46 am

Hi,

We're certainly glad to hear that you are enjoying CodeSite.

As for your request, it is not currently possible to create new views in the viewers from the messages that are logged. It is certainly something that we can look into for a future release.

In the meantime, I do have a couple suggestions. First, instead of using a single logger instance and changing the Category property before each Send method, I would suggest creating separate loggers. That is, for your error logging, create a separate TCodeSiteLogger instance and set the Category property at creation. You may also wish to set the CategoryColor and CategoryFontColor properties. For example,

Code: Select all
csError := TCodeSiteLogger.Create( Self );
csError.Category := 'Error';
csError.CategoryColor := RGB( 200, 0, 0 );
csError.CategoryFontColor := RGB( 255, 255, 255 );


For the application logging messages, you can either create another TCodeSiteLogger instance or simply use the general purpose instance named "CodeSite".

Setting the CategoryColor really makes the error messages stand out in the viewer. However, another really nice benefit of using separate loggers, is that you can set their Enabled properties independently. For example, you will probably always want to have the csError logger always enabled. However, you may decided to provide an option to turn off regular logging. Or perhaps you create additional loggers based on certain features in your application and you can control those as well.

Of course, no loggers will send messages if the CodeSiteManager.Enabled property is set to False. So that is another way of control the amount of messages that are generated.

Hope this helps,
Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 603
Joined:
Fri Mar 25, 2011 9:04 pm


Return to Loggers

Who is online

Users browsing this forum: No registered users and 1 guest

cron