libsim Versione 7.2.6
|
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. | |
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 <config> element controls the global log4c configuration. It has 3 sub elements. The <nocleanup> flag inhibits the log4c destructors routines. The <bufsize> element sets the buffer size used to format log4c_logging_event_t objects. If is set to 0, the allocation is dynamic (the <debug> element is currently unused). The <category> element has 3 possible attributes: the category "name", the category "priority" and the category "appender". Future versions will handle multple appenders per category. The <appender> element has 3 possible attributes: the appender "name", the appender "type", and the appender "layout". The <layout> 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
Here's one sample log4crc configuration file