log4tran Code
Status: Planning
Brought to you by:
dsuarez
| File | Date | Author | Commit |
|---|---|---|---|
| Makefile | 2007-11-21 | dsuarez | [r3] README is now a little bit more professional an... |
| README | 2007-11-21 | dsuarez | [r2] README is now a little bit more professional an... |
| log4tran.f95 | 2007-11-21 | dsuarez | [r1] Import inicial |
log4tran
David Suarez Perera
Version 1.0
Academic Free License
21/11/2007
========================
1. Features
2. Installation
3. Linking your programs
4. Usage
------------------------
1. Features
- Able to write output to file, stdout or stderr
- Four levels of output (BASIC, INFO, DETAIL, DEBUG)
------------------------
2. Installation
Just do make.
$ make
This command creates the liblog4tran.a library
------------------------
3. Linking your programs
You have to link against the library liblog4tran.a. For instante:
$ g95 program1.f95 -L/path/to/log4tran/lib -llog4tran -I/path/to/log4tran/module
where in the -L you have to specify the location of liblog4tran.a and in the -I you
have to specify the location of log4tran.mod file.
------------------------
4. Usage
Module log4tran includes 5 special units. One for each detail level of logging.
The trick is to redirect not used units (the ones more detailed than the loglevel specified) to
/dev/null.
Take it easy. I think next example is enough.
program Risas
use log4tran
integer :: lev
!! set level
!! lev = BASIC
!! lev = INFO
!! lev = DETAIL
!! lev = DEBUG
lev = INFO
call setLogLevel(lev)
!! Do one of:
!!call setStdout
!!call setStderr
!!call openlog('logfile.log', 666, lev) ! 666 is the unit number for the output log file, repeat lev please!
call setStdout
write (ulog, *) '[ERROR] blah blah blah' ! it always writes to ulog special unit (stdout in the example)
!! Because loglevel is INFO, only the two next sentences will be written to the log device
write (logbasic, *) '[BASIC] basic basic basic' ! basic level info is the lowest detail level
write (loginfo, *) '[INFO] info info info' ! info level info is the 2nd detail level
write (logdet, *) '[DETAIL] details details details' ! detail level info is the 3rd detail level
write (logdebug, *) '[DEBUG] debug debug debug' ! debug level info is the 4th detail level
!! call closelog ! if openlog option was used
end program Risas
------------------------