Welcome to the LogLib home page
- Basic Functionality
- Current status
The LogLib library project is a collection of libraries and programs that can be used to add log file functionality to a program and offer tools to use and analyze the log files.
At the core of this is the LogFiles library, a C++ library that provides a class that are used to maintain a log file for a program. The class will manage the log file internally. The class supports different log levels that can be changed on the fly.
There are tools planned that can be used to view and analyze the log file easily, as well as tools to manage the log files on a computer, to ensure that disks pace is not used up and archives are kept.
Back to top
The log file
The class allows you to specify a base name for the log file, the path to where the log file should be created, the log level to use, whether a new file should be created at midnight and whether an existing file should be replaced or appended to.
The file name is then made up of the base name with a date-stamp appended to it and a .log extension, like so:
By default, a new log file will be created the first time a message is written to the log after midnight.
The following log severities can be used:
The log level that is specified for the log file is a combination of these severities. When a message is written to the log, it is assigned one of these log severities. Only messages with a severity that is part of the log file's log level combination is written.
This enables you to only log messages of certain levels. The log file's log level can be changed to a different combination, so that other messages will be written.
You would normally only want to see messages that is Critical, Error and Warning. Then you set the log level to CRITICAL || ERROR || WARNING.
Then, for instance, your program is not behaving as expected or it is processing data wrong. Now you want to see the Trace and Debug messages too. Just change the log file's log level to include TRACE and DEBUG too. Then you will start seeing your Debug and Trace messages as well.
Log File Format
Messages are written to the log file with a time stamp and it's severity, like so:
[timestamp] [severity] : [message]
10:12:34 DEBUG : This is a test message
To use the log file, you include the library in your C++ project and instantiate the LogFiles class. Call the Open function to open the log file and the Close function to close the file. The Open and Close functions can be used to enable or disable logging in your program on the fly. When the log file is closed, the Write functions will just be ignored.
Use the Write function to write messages to the log file. The Write function takes 3 parameters:
|unsigned int msglevel
||- The message severity
||- The message format or text (same as printf)
||- The message parameters (same as printf)
int i = 0;
char theStr = "The String";
myLogFile->Write( MSG_DEBUG, "This is test no %d, and string is: %s", i, theStr );
The message in the log file will look like this:
15:44:45 DEBUG : This is test no 0, and string is: The String
Back to top
Supported Platforms and compilers
The following platforms and compilers are supported:
- gcc (This should also work on any UNIX platform that support gcc)
- Kylix 3
- Borland C++ Builder 6
- Borland Delphi 7 (using the loglib DLL) [Should also work for earlier versions of Delphi]
- MS Visual C++ 6
- MS Visual Basic 6 (using the loglib DLL)
Contents of project
The project currently consist of the following parts:
- The LogLib source code
- Makefile to compile the library with gcc
- Borland C++ Builder 6 project to compile the library
- Borland Kylix3 project to compile the library
- MS Visual C++ 6 project to compile the library
- Small test application for gcc to test the library
- Small test application for Borland C++ Builder 6 to test the library
- Borland C++ Builder 6 project to compile the DLL
- Borland Delphi wrapper Unit for using the DLL
- Borland Delphi 7 Test project, for testing the DLL
- MS Visual Basic wrapper module for using the DLL
- MS Visual Basic 6 Test project, for testing the DLL
Back to top
Here is a list of what I have planned so far:
- Add a C shared object library to the project. The library already exist. It just needs a makefile and install
- Add the Windows log file viewer after I upgrraded it
- Add sysntax highlighting to the log file viewer
- Port the log file viewer to Kylix
- Create a ncurses or text based log file viewer with syntax highlighting for teminal use on Linux/Unix
- Extend the current test programs to test the library more thoughly
- Add functionality to the LogLib class to limit a log file to a certain size
Back to top
The project page. at SourceForge
Instructions for anonymous cvs access
View the source files in the CVS Web repository
Project Mailing Lists
Back to top