![]() |
(git:9754b87)
|
various routines to log and control the output. The idea is that decisions about where to log should not be done in the code that generates the log, but should be globally changeable a central place. So some care has been taken to have enough information about the place from where the log comes so that in the future intelligent and flexible decisions can be taken by the logger, without having to change other code. More...
Data Types | |
type | cp_logger_p_type |
type | cp_logger_type |
type of a logger, at the moment it contains just a print level starting at which level it should be logged (0 note, 1 warning, 2 failure, 3 fatal) it could be expanded with the ability to focus on one or more module/object/thread/processor More... | |
interface | cp_to_string |
Functions/Subroutines | |
integer function, public | cp_default_logger_stack_size () |
... | |
subroutine, public | cp_add_default_logger (logger) |
adds a default logger. MUST be called before logging occours | |
subroutine, public | cp_rm_default_logger () |
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has been | |
type(cp_logger_type) function, pointer, public | cp_get_default_logger () |
returns the default logger | |
subroutine, public | cp_logger_create (logger, para_env, print_level, default_global_unit_nr, default_local_unit_nr, global_filename, local_filename, close_global_unit_on_dealloc, iter_info, close_local_unit_on_dealloc, suffix, template_logger) |
initializes a logger | |
subroutine, public | cp_logger_retain (logger) |
retains the given logger (to be called to keep a shared copy of the logger) | |
subroutine, public | cp_logger_release (logger) |
releases this logger | |
logical function, public | cp_logger_would_log (logger, level) |
this function can be called to check if the logger would log a message with the given level from the given source you should use this function if you do direct logging (without using cp_logger_log), or if you want to know if the generation of some costly log info is necessary | |
integer function, public | cp_logger_get_unit_nr (logger, local) |
returns the unit nr for the requested kind of log. | |
integer function, public | cp_logger_get_default_io_unit (logger) |
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs calling this function is not the ionode | |
subroutine, public | cp_logger_set_log_level (logger, level) |
changes the logging level. Log messages with a level less than the one given wo not be printed. | |
recursive integer function, public | cp_logger_get_default_unit_nr (logger, local, skip_not_ionode) |
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr | |
subroutine, public | cp_logger_generate_filename (logger, res, root, postfix, local) |
generates a unique filename (ie adding eventual suffixes and process ids) | |
subroutine, public | cp_logger_set (logger, local_filename, global_filename) |
sets various attributes of the given logger | |
Variables | |
integer, parameter, public | cp_fatal_level = 3 |
integer, parameter, public | cp_failure_level = 2 |
integer, parameter, public | cp_warning_level = 1 |
integer, parameter, public | cp_note_level = 0 |
various routines to log and control the output. The idea is that decisions about where to log should not be done in the code that generates the log, but should be globally changeable a central place. So some care has been taken to have enough information about the place from where the log comes so that in the future intelligent and flexible decisions can be taken by the logger, without having to change other code.
At the moment logging and output refer to the same object (cp_logger_type) as these are actually different it might be better to separate them (they have already separate routines in a separate module
some practices (use of print *, no cp_error_type, manual retain release of some objects) are dictated by the need to have minimal dependency
integer function, public cp_log_handling::cp_default_logger_stack_size |
...
Definition at line 172 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_add_default_logger | ( | type(cp_logger_type), intent(inout), target | logger | ) |
adds a default logger. MUST be called before logging occours
logger | ... |
Definition at line 187 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_rm_default_logger |
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has been
Definition at line 212 of file cp_log_handling.F.
type(cp_logger_type) function, pointer, public cp_log_handling::cp_get_default_logger |
returns the default logger
Definition at line 233 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_logger_create | ( | type(cp_logger_type), pointer | logger, |
type(mp_para_env_type), optional, pointer | para_env, | ||
integer, intent(in), optional | print_level, | ||
integer, intent(in), optional | default_global_unit_nr, | ||
integer, intent(in), optional | default_local_unit_nr, | ||
character(len=*), intent(in), optional | global_filename, | ||
character(len=*), intent(in), optional | local_filename, | ||
logical, intent(in), optional | close_global_unit_on_dealloc, | ||
type(cp_iteration_info_type), optional, pointer | iter_info, | ||
logical, intent(in), optional | close_local_unit_on_dealloc, | ||
character(len=*), intent(in), optional | suffix, | ||
type(cp_logger_type), optional, pointer | template_logger | ||
) |
initializes a logger
logger | the logger to initialize |
para_env | the parallel environment (this is most likely the global parallel environment |
print_level | the level starting with which something is written (defaults to cp_note_level) |
default_global_unit_nr | the default unit_nr for output (if not given, and no file is given defaults to the standard output) |
default_local_unit_nr | the default unit number for local (i.e. task) output. If not given defaults to a out.taskid file created upon |
global_filename | a new file to open (can be given instread of the global_unit_nr) |
local_filename | a new file to open (with suffix and para_envmepos appended). Can be given instread of the default_local_unit_nr). the file is created only upon the first local logging request |
close_global_unit_on_dealloc | if the unit should be closed when the logger is deallocated (defaults to true if a local_filename is given, to false otherwise) |
iter_info | ... |
close_local_unit_on_dealloc | if the unit should be closed when the logger is deallocated (defaults to true) |
suffix | the suffix that should be added to all the generated filenames |
template_logger | a logger from where to take the unspecified things |
Definition at line 281 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_logger_retain | ( | type(cp_logger_type), intent(inout) | logger | ) |
retains the given logger (to be called to keep a shared copy of the logger)
logger | the logger to retain |
Definition at line 404 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_logger_release | ( | type(cp_logger_type), pointer | logger | ) |
releases this logger
logger | the logger to release |
Definition at line 422 of file cp_log_handling.F.
logical function, public cp_log_handling::cp_logger_would_log | ( | type(cp_logger_type), pointer | logger, |
integer, intent(in) | level | ||
) |
this function can be called to check if the logger would log a message with the given level from the given source you should use this function if you do direct logging (without using cp_logger_log), or if you want to know if the generation of some costly log info is necessary
logger | the logger you want to log in |
level | describes the of the message: cp_fatal_level(3), cp_failure_level(2), cp_warning_level(1), cp_note_level(0). |
Definition at line 467 of file cp_log_handling.F.
integer function, public cp_log_handling::cp_logger_get_unit_nr | ( | type(cp_logger_type), pointer | logger, |
logical, intent(in), optional | local | ||
) |
returns the unit nr for the requested kind of log.
logger | the logger you want to log in |
local | if true returns a local logger (one per task), otherwise returns a global logger (only the process with para_envmepos== para_envsource should write to the global logger). Defaults to false |
Definition at line 497 of file cp_log_handling.F.
integer function, public cp_log_handling::cp_logger_get_default_io_unit | ( | type(cp_logger_type), optional, pointer | logger | ) |
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs calling this function is not the ionode
logger | the logger you want to log in |
Definition at line 514 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_logger_set_log_level | ( | type(cp_logger_type), intent(inout) | logger, |
integer, intent(in) | level | ||
) |
changes the logging level. Log messages with a level less than the one given wo not be printed.
logger | the logger to change |
level | the new logging level for the logger |
Definition at line 543 of file cp_log_handling.F.
recursive integer function, public cp_log_handling::cp_logger_get_default_unit_nr | ( | type(cp_logger_type), optional, pointer | logger, |
logical, intent(in), optional | local, | ||
logical, intent(in), optional | skip_not_ionode | ||
) |
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
logger | the logger you want info from |
local | if you want the local unit nr (defaults to false) |
skip_not_ionode | ... |
Definition at line 566 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_logger_generate_filename | ( | type(cp_logger_type), pointer | logger, |
character(len=*), intent(inout) | res, | ||
character(len=*), intent(in) | root, | ||
character(len=*), intent(in) | postfix, | ||
logical, intent(in), optional | local | ||
) |
generates a unique filename (ie adding eventual suffixes and process ids)
logger | ... |
res | the resulting string |
root | the start of filename |
postfix | the end of the name |
local | if the name should be local to this task (defaults to false) |
Definition at line 677 of file cp_log_handling.F.
subroutine, public cp_log_handling::cp_logger_set | ( | type(cp_logger_type), intent(inout) | logger, |
character(len=*), intent(in), optional | local_filename, | ||
character(len=*), intent(in), optional | global_filename | ||
) |
sets various attributes of the given logger
logger | the logger you want to change |
local_filename | the root of the name of the file used for local logging |
global_filename | the root of the name of the file used for global logging |
Definition at line 716 of file cp_log_handling.F.
integer, parameter, public cp_log_handling::cp_fatal_level = 3 |
Definition at line 81 of file cp_log_handling.F.
integer, parameter, public cp_log_handling::cp_failure_level = 2 |
Definition at line 83 of file cp_log_handling.F.
integer, parameter, public cp_log_handling::cp_warning_level = 1 |
Definition at line 85 of file cp_log_handling.F.
integer, parameter, public cp_log_handling::cp_note_level = 0 |
Definition at line 87 of file cp_log_handling.F.