Usage Scenarios (together with code)





The easy way, use Named Formatters and Destinations

You use a string to specify Formatters, and a string to specify Destinations. Thus, you use the writer::named_write.

First, the examples: example 1, example 2


The manual way

First, the examples: example 1, example 2




Scenario 1, Common usage: Multiple levels, One logging class, Multiple destinations.

Scenario 1 should be the most common.

This usage:

In this example, all output will be written to the console, debug output window, and "out.txt" file. It will look similar to this one:

21:03.17.243 [1] this is so cool 1
21:03.17.243 [2] first error 2
21:03.17.243 [3] hello, world
21:03.17.243 [4] second error 3
21:03.17.243 [5] good to be back ;) 4
21:03.17.243 [6] third error 5

Click to see the code


Scenario 2: No levels, One Logger, One Filter

This usage:

Optimizations:

In this example, all output will be written to the console, debug window, and "out.txt" file. It will be:

[1] this is so cool 1
[2] this is so cool again 2
[3] hello, world
[4] good to be back ;) 3

Click to see the code


Scenario 3: Fastest: Multiple Loggers, One Filter, Not using Formatters/Destinations, Not using <<

This usage:

Here's what the output will be:

The console:

this is so cool
hello, world
good to be back ;)

The err.txt file:

first error 
second error 

Click to see the code


Your Scenario : Find out logger and filter, based on your application's needs

This usage:

Optimizations:

Logs:

Here's how the output will look like:

The debug output window:

18:59.24 this is so cool 1
18:59.24 this is so cool again 2

The console:

18:59.24 this is so cool 1
18:59.24 this is so cool again 2
18:59.24 hello, world
18:59.24 good to be back ;) 4

The out.txt file:

18:59.24 hello, world
18:59.24 good to be back ;) 4

The err.txt file

18:59.24 [1] first error 3
18:59.24 [2] second error 5

Click to see the code




Copyright John Torjo © 2007
Have a question/ suggestion/ comment? Send me feedback