PC Review


Reply
Thread Tools Rate Thread

Conditional Log messages

 
 
Steven Blair
Guest
Posts: n/a
 
      22nd Jan 2007
Hi,

My application requires 3 different types of logging:

Standard
Debug
Performance

I want an approach that can easily allow the user to do this:

At the moment, my code looks something like this:

//To display some standard log message
WriteLog( myMsg );

//To display a debug message
if( _debug )
{
WriteLog( myMsg );
}

//To display a performance message
if( _performance )
{
WriteLog( myMsg );
}

This bloats the code a little.

The other approach is to have a wrapper call for each.
For debug:

public void DebugMessage( string msg )
{
if( _debug )
{
WriteLog( myMsg );
}
}

Disadvantage is the code would always call the wrapper function, even if
_debug is false.

So, I am looking for a solution to this problem which reduces the amount
of of times _debug and _performance is used,
but does not have lots of redundant method calls.

Any ideas?

Using soemthing like #DEBUG is not an option either, since the logging
is configurable.

Thanks in advance for the help.

Steven



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
peter
Guest
Posts: n/a
 
      22nd Jan 2007
"Steven Blair" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> Any ideas?
>
> Using soemthing like #DEBUG is not an option either, since the logging
> is configurable.
>
> Thanks in advance for the help.


Use Log4Net?
http://logging.apache.org/log4net/


 
Reply With Quote
 
Steven Blair
Guest
Posts: n/a
 
      22nd Jan 2007
I have a log library which needs to be used.
The problem is when it's used.



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      22nd Jan 2007
Hi,

I would do something like your second option (create a method) but I would
have the same method no matter the source of the debugging.

Inside the method you could check for the status of the particular debugging
and simply ignore it or log it.
Of course this has some overhead but no matter what you do the overhead will
be present in one way or other.

You could do like:

void Log( string msg, DebugInfoType debugType)
{
switch ) debugType:
case Standard:
////
case Debug
if ( _debug )

}


--
Ignacio Machin
machin AT laceupsolutions com


"Steven Blair" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
| Hi,
|
| My application requires 3 different types of logging:
|
| Standard
| Debug
| Performance
|
| I want an approach that can easily allow the user to do this:
|
| At the moment, my code looks something like this:
|
| //To display some standard log message
| WriteLog( myMsg );
|
| //To display a debug message
| if( _debug )
| {
| WriteLog( myMsg );
| }
|
| //To display a performance message
| if( _performance )
| {
| WriteLog( myMsg );
| }
|
| This bloats the code a little.
|
| The other approach is to have a wrapper call for each.
| For debug:
|
| public void DebugMessage( string msg )
| {
| if( _debug )
| {
| WriteLog( myMsg );
| }
| }
|
| Disadvantage is the code would always call the wrapper function, even if
| _debug is false.
|
| So, I am looking for a solution to this problem which reduces the amount
| of of times _debug and _performance is used,
| but does not have lots of redundant method calls.
|
| Any ideas?
|
| Using soemthing like #DEBUG is not an option either, since the logging
| is configurable.
|
| Thanks in advance for the help.
|
| Steven
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply a conditional Select distinct (or conditional Where onduplicated cell values in a column) Jamie Microsoft Access Queries 3 2nd Oct 2009 07:39 PM
Conditional Formatting No Longer Conditional in 2007 Beta =?Utf-8?B?Q2FjdHVhci1Oby1KdXRzdQ==?= Microsoft Excel Crashes 0 17th Nov 2006 10:01 PM
Using query results within Conditional Statement...sequenced conditional queries rafael.farias.jr@gmail.com Microsoft Access 3 30th Aug 2006 02:08 PM
How do I do a complex conditional in a conditional formatting formula Ray Stevens Microsoft Excel Discussion 7 12th Mar 2006 10:24 PM
Re: Multiple conditional on conditional format formula Bob Phillips Microsoft Excel Programming 0 27th Jul 2004 05:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:57 PM.