libsim Versione 7.2.6
Riferimenti per il modulo log4fortran

classe per la gestione del logging Continua...

Tipi di dato

interface  l4f_category_exist
 Return true if the corresponding category handle exists. Continua...
 
interface  l4f_category_get_c
 Initialize a logging category. Continua...
 
interface  l4f_category_log
 Emit log message for a category with specific priority. Continua...
 
interface  l4f_fini
 log4fortran destructor Continua...
 
type  l4f_handle
 l4f handle. Continua...
 
interface  l4f_init
 Global log4fortran constructor. Continua...
 

Funzioni/Subroutine

subroutine, public l4f_launcher (a_name, a_name_force, a_name_append)
 Ritorna un messaggio caratteristico delle priorità standard.
 
integer function, public l4f_category_get (a_name)
 Initialize a logging category.
 
type(l4f_handle) function l4f_category_get_handle (a_name)
 Initialize a logging category.
 
subroutine l4f_category_delete_legacy (a_category)
 Delete a logging category.
 
subroutine l4f_category_delete_f (a_category)
 Delete a logging category.
 
subroutine l4f_category_log_f (a_category, a_priority, a_format)
 Emit log message for a category with specific priority.
 
subroutine l4f_category_log_legacy (a_category, a_priority, a_format)
 Emit log message for a category with specific priority.
 
subroutine, public l4f_log (a_priority, a_format)
 Emit log message without category with specific priority.
 
logical function l4f_category_exist_f (a_category)
 Return true if the corresponding category handle exists (is associated with a category).
 
logical function l4f_category_exist_legacy (a_category)
 Return true if the corresponding category handle exists (is associated with a category).
 

Variabili

integer(kind=c_int), parameter, public l4f_fatal = 000
 standard priority
 
integer(kind=c_int), parameter, public l4f_alert = 100
 standard priority
 
integer(kind=c_int), parameter, public l4f_crit = 200
 standard priority
 
integer(kind=c_int), parameter, public l4f_error = 300
 standard priority
 
integer(kind=c_int), parameter, public l4f_warn = 400
 standard priority
 
integer(kind=c_int), parameter, public l4f_notice = 500
 standard priority
 
integer(kind=c_int), parameter, public l4f_info = 600
 standard priority
 
integer(kind=c_int), parameter, public l4f_debug = 700
 standard priority
 
integer(kind=c_int), parameter, public l4f_trace = 800
 standard priority
 
integer(kind=c_int), parameter, public l4f_notset = 900
 standard priority
 
integer(kind=c_int), parameter, public l4f_unknown = 1000
 standard priority
 
integer(kind=c_int), public l4f_priority =L4F_NOTICE
 Default priority value.
 

Descrizione dettagliata

classe per la gestione del logging

Questo modulo permette una semplice, ma potente gestione della messagistica. E' utile sia in fase di debug che di monitoraggio utente.

Questo modulo fornisce funzionalità simili, ma non identiche a seconda che siano disponibili in fase di compilazione le librerie log4c e cnf.

There are three fundamental types of object in Log4C: categories, appenders and layouts. You can think of these objects as corresponding to the what, where and how of the logging system: categories describe what sub-system the message relates to, appenders determine where the message goes and layouts determine how the message is formatted.

First, you have to figure out what kind of categories you want. Maybe you want one logger for GUI code and another one for memory management and a third one for user access logging. Okay. That's fine. Me, I like to have a separate logger for each class or data structure. I've already gone to the trouble of breaking my code down into such categories. Why not just use those? Feel free to set it up any way you like. Just don't make the mistake of using message severity as your categories. That's what the priority is all about.

La gestione di appenders e layouts viene demandata in toto al file di configurazione di log4c (vedere apposita documentazione http://log4c.cvs.sourceforge.net/*checkout*/log4c/log4c/doc/Log4C-DevelopersGuide.odt )

log4fortran by default can log messages with some standard priority levels:

Use debug to write debugging messages which should not be printed when the application is in production.

Use info for messages similar to the "verbose" mode of many applications.

Use warn for warning messages which are logged to some log but the application is able to carry on without a problem.

Use error for application error messages which are also logged to some log but, still, the application can hobble along. Such as when some administrator-supplied configuration parameter is incorrect and you fall back to using some hard-coded default value.

Use fatal for critical messages, after logging of which the application quits abnormally.

Configuration syntax:

The log4crc configuration file uses an XML syntax. The root element is <log4c> and it can be used to control the configuration file version interface with the attribute "version". The following 4 elements are supported: <config>, <category>, <appender> and <layout>.

 The &lt;config&gt; element controls the global log4c
 configuration. It has 3 sub elements. The &lt;nocleanup&gt; flag
 inhibits the log4c destructors routines. The &lt;bufsize&gt; element
 sets the buffer size used to format log4c_logging_event_t
 objects. If is set to 0, the allocation is dynamic (the &lt;debug&gt;
 element is currently unused).

 The &lt;category&gt; element has 3 possible attributes: the category
 "name", the category "priority" and the category
 "appender". Future versions will handle multple appenders per
 category.

 The &lt;appender&gt; element has 3 possible attributes: the appender
 "name", the appender "type", and the appender "layout".

 The &lt;layout&gt; element has 2 possible attributes: the layout
 "name" and the layout "type".

This initial version of the log4c configuration file syntax is quite different from log4j. XML seemed the best choice to keep the log4j configuration power in a C API. Environment variables

 LOG4C_RCPATH holds the path to the main log4crc configuration file
 LOG4C_PRIORITY holds the "root" category priority
 LOG4C_APPENDER holds the "root" category appender

Programma esempio

! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
! authors:
! Davide Cesari <dcesari@arpa.emr.it>
! Paolo Patruno <ppatruno@arpa.emr.it>
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation; either version 2 of
! the License, or (at your option) any later version.
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
program testlog
integer :: category,ier
character(len=512):: a_name
!it's very easy
call very_easy_log()
!questa chiamata prende dal launcher il nome univoco
call l4f_launcher(a_name)
!init di log4fortran
ier=l4f_init()
!change the default verbosity level (dummy routine only !)
l4f_priority=l4f_debug
!imposta a_name
category=l4f_category_get(a_name)
call l4f_category_log(category,l4f_error,"erroraccio in log4fortran")
call l4f_category_log(category,l4f_info,"info in log4fortran")
! aggiungo una comunicazione in stderr
write(0,*) "erroraccio in stderr"
call logexample()
!chiudo il logger
call l4f_category_delete(category)
ier=l4f_fini()
!aggiungo una comunicazione in stdout
write(6,*) "l4f_fini",ier
contains
subroutine very_easy_log()
CALL l4f_log(l4f_info,"nothing is more easy")
return
end subroutine very_easy_log
subroutine logexample()
character(len=512):: a_name
integer :: false_category=-1,local_category
!questa chiamata prende dal launcher il nome univoco
call l4f_launcher(a_name)
local_category=l4f_category_get(trim(a_name)//".logexample")
CALL l4f_category_log(local_category,l4f_debug,"inizia logexample")
call spassosa(false_category)
!chiudo la category
call l4f_category_delete(local_category)
end subroutine logexample
subroutine spassosa(category)
character(len=512):: a_name
integer :: local_category,category
!questa chiamata prende dal launcher il nome univoco
call l4f_launcher(a_name)
if (l4f_category_exist(category)) then
CALL l4f_category_log(category,l4f_debug,"inizia lo spasso")
CALL l4f_category_log(category,l4f_error,"lo spasso non riesce bene")
else
local_category=l4f_category_get(trim(a_name)//".spassosa")
CALL l4f_category_log(local_category,l4f_debug,"inizia lo spasso")
CALL l4f_category_log(local_category,l4f_error,"lo spasso non riesce bene")
!chiudo la category
call l4f_category_delete(local_category)
end if
end subroutine spassosa
end program testlog
Return true if the corresponding category handle exists.
Emit log message for a category with specific priority.
log4fortran destructor
Global log4fortran constructor.
classe per la gestione del logging

Here's one sample log4crc configuration file

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4c SYSTEM "">
<log4c version="1.2.1">
<config>
<bufsize>0</bufsize>
<debug level="0"/>
<nocleanup>0</nocleanup>
</config>
<!-- root category ========================================= -->
<!-- <category name="root" priority="debug" appender="syslog"/> -->
<category name="root" priority="debug" appender="stdout"/>
<!-- <category name="root" priority="error" appender="stderr"/> -->
<!-- <category name="root" priority="debug" appender="myappender"/> -->
<!-- default appenders ===================================== -->
<appender name="stdout" type="stream" layout="basic"/>
<appender name="stderr" type="stream" layout="dated"/>
<appender name="syslog" type="syslog" layout="basic"/>
<appender name="myappender" type="stream" layout="mylayout"/>
<!-- default layouts ======================================= -->
<layout name="basic" type="basic"/>
<layout name="dated" type="dated"/>
<layout name="mylayout" type="%m"/>
</log4c>

Generated with Doxygen.