1. What is it?
2. Getting it
3. Usage
4. Compiling
5. Modifiers
6. Example
7. Author

1. What is it?

This project intends to provide C++ programmers with an easy interface to logging facilities such as stderr, log files, syslog, and others that might come in handy latter on. The interface is provided by global std::ostream objects similar to cout and cerr, this way the programmer can easylly port programs to this library and take advantage off all user defined redefinitions of operator<<.
Another of it's main features is the possibility of defining debug levels, for wich only inferior levels would be outputed, for example:

lerr << setDebugLevel(2) << level(1) << "hello" << level(3) << "world" << endl;

would print:


since our stream DebugLevel is 2.
This project came from the need to have a really simple interface to debug, and the inability to find a similar library wich could be used, with such a minimal set of modifications to code already written using cout and cerr.

2. Getting it:

You can find it in logstream sourceforge project site

Directly download it from here

Or access CVS from here

3. Usage:

In your source code add:
#include <log.h>
use the following static objects:
lerr (stderr output)
lsyslog (syslog output)
as you would use cout or cerr.

4. Compiling:

Just add to your makefile:

g++ ... -L/path/to/liblogstream.so -llogstream ...

Attention: -L/path/to/liblogstream is optional, since you can have liblogstream.so path in your LD_PATH_LIBRARY enviroment variable or /etc/ld.so.conf file.

5. Modifiers:

setDebugLeve(int v) sets the Debug level of the object to v
level(int v) sets stream debug level to v
setIdent(char *identification) The string pointed to by identification is prepended to every message, and is typically set to the program name.

6. Example:

#include <iostream>
#include <log.h>
using namespace std;
using namespace logstream;

int main(int argc, char *argv[])

lerr << setDebugLevel(1) <<"Hello world" << endl;
lsyslog << setDebugLevel(2) << setIdent(argv[0]) << "testing syslog" << endl;
lsyslog << level(3) << "This is won't reach syslog" << endl;
lerr << level(1) << "Started doing something"<< endl;
lerr << level(2) << "You don't need to know what I'm doing" << endl;
lerr << level(1) << "All done :)" << endl;
return 0;


7. Author:

Find more about me and my interest here
For bugs, contributions, comments and requests email me :)

Thanks to SourceForge.net Logo

Last Update April 1, 2003 1:48 AM