@@ -8,19 +8,20 @@ title: logger
88## Introduction
99
1010This module defines a derived type, its methods, a variable, and
11- constants to be used for the reporting of errors and other
12- information. The derived type, ` logger_type ` , is to be used to define
13- both global and local logger variables. The ` logger_type ` methods serve
14- to configure the loggers and use the logger variables to report
15- messages to a variable specific list of I/O units termed
16- ` log_units ` . The variable, ` global_logger ` , of type ` logger_type ` , is
17- intended to serve as the default global logger. The constants serve as
18- error flags returned by the optional integer ` stat ` argument.
11+ constants to be used for the reporting of errors, displaying messages,
12+ and other information. The derived type, ` logger_type ` , is to be used
13+ to define both global and local logger variables. The ` logger_type `
14+ methods serve to configure the loggers and use the logger variables to
15+ report messages to a variable specific list of I/O units termed
16+ ` log_units ` . The variable, ` global_logger ` , of type ` logger_type ` ,
17+ is intended to serve as the default global logger. The constants serve
18+ as error flags returned by the optional integer ` stat ` argument.
1919
2020The logger variables have the option to:
2121
2222* change which units receive the log messages;
2323* report which units receive the log messages;
24+ * select which types of messages are logged;
2425* precede messages by a blank line;
2526* precede messages by a time stamp of the form
2627 ` yyyy-mm-dd hh:mm:ss.sss ` ;
@@ -64,6 +65,18 @@ Error Code | Description
6465` unopened_in_error ` | the unit was not opened
6566` write_fault ` | one of the writes to ` log_units ` failed
6667
68+ The module also defines eight distinct public integer constants for
69+ selecting the messages that are logged. These constants, termed
70+ severity levels, are (sorted following their increasing order of
71+ severity): ` all_level ` , ` debug_level ` , ` information_level ` ,
72+ ` warning_level ` , ` error_level ` , ` io_error_level ` , ` text_error_level ` ,
73+ and ` none_level ` .
74+ All log messages with a level (e.g., ` debug_level ` ) lower than a
75+ specified severity level (e.g., ` information_level ` ) will be ignored.
76+ The levels ` error_level ` and ` io_error_level ` have the same severity.
77+ The default severity level is ` information_level ` .
78+
79+
6780## The derived type: logger_type
6881
6982### Status
@@ -81,14 +94,15 @@ significant events encountered during the execution of a program.
8194
8295### Private attributes
8396
84- | Attribute | Type | Description | Initial value |
85- | ------------------| ---------------| -------------------------------------------------| --------------|
86- | ` add_blank_line ` | Logical | Flag to precede output with a blank line | ` .false. ` |
87- | ` indent_lines ` | Logical | Flag to indent subsequent lines by four columns | ` .true. ` |
88- | ` log_units ` | Integer array | List of I/O units used for output | Unallocated |
89- | ` max_width ` | Integer | Maximum column width of output | 0 |
90- | ` time_stamp ` | Logical | Flag to precede output by a time stamp | ` .true. ` |
91- | ` units ` | Integer | Count of the number of active output units | 0 |
97+ | Attribute | Type | Description | Initial value |
98+ | ------------------| ---------------| -------------------------------------------------| ---------------------|
99+ | ` add_blank_line ` | Logical | Flag to precede output with a blank line | ` .false. ` |
100+ | ` indent_lines ` | Logical | Flag to indent subsequent lines by four columns | ` .true. ` |
101+ | ` level ` | Integer | Severity level | ` information_level ` |
102+ | ` log_units ` | Integer array | List of I/O units used for output | Unallocated |
103+ | ` max_width ` | Integer | Maximum column width of output | 0 |
104+ | ` time_stamp ` | Logical | Flag to precede output by a time stamp | ` .true. ` |
105+ | ` units ` | Integer | Count of the number of active output units | 0 |
92106
93107## The ` stdlib_logger ` variable
94108
@@ -284,7 +298,7 @@ Reports the configuration of a logger.
284298
285299#### Syntax
286300
287- ` call self % [[logger_type(type):configuration(bound)]]( [ add_blankline, indent, max_width, time_stamp, log_units ] ) `
301+ ` call self % [[logger_type(type):configuration(bound)]]( [ add_blankline, indent, level, max_width, time_stamp, log_units ] ) `
288302
289303#### Class
290304
@@ -303,6 +317,10 @@ Pure subroutine
303317 is an ` intent(out) ` argument. A value of ` .true. ` indents subsequent
304318 lines by four spaces, and ` .false. ` otherwise.
305319
320+ ` level ` (optional): shall be a scalar default integer variable. It is an
321+ ` intent(out) ` argument. The value corresponds to the severity level for
322+ ignoring a message.
323+
306324` max_width ` (optional): shall be a scalar default integer
307325 variable. It is an ` intent(out) ` argument. A positive value bigger
308326 than four defines the maximum width of the output, otherwise there
@@ -355,7 +373,7 @@ Configures the logging process for self.
355373
356374#### Syntax
357375
358- ` call self % [[logger_type(type):configure(bound)]]( [ add_blank_line, indent, max_width, time_stamp ] ) `
376+ ` call self % [[logger_type(type):configure(bound)]]( [ add_blank_line, indent, level, max_width, time_stamp ] ) `
359377
360378#### Class
361379
@@ -375,6 +393,10 @@ Pure subroutine
375393 indent subsequent lines by four spaces, and to ` .false. ` to
376394 not indent.
377395
396+ ` level ` (optional): shall be a scalar default integer expression. It is
397+ an ` intent(in) ` argument. Set the severity level for ignoring a log
398+ message.
399+
378400` max_width ` (optional): shall be a scalar default integer
379401 expression. It is an ` intent(in) ` argument. Set to a positive value
380402 bigger than four to define the maximum width of the output,
@@ -416,6 +438,8 @@ If time stamps are active, a time stamp is written, followed
416438by ` module ` and ` procedure ` if present, and then
417439` message ` is written with the prefix ` 'DEBUG: ' ` .
418440
441+ It is ignored if the ` level ` of ` self ` is higher than ` debug_level ` .
442+
419443#### Class
420444
421445Subroutine
@@ -486,6 +510,8 @@ followed by `module` and `procedure` if present, then
486510` message ` is written with the prefix ` 'ERROR: ' ` , and then
487511if ` stat ` or ` errmsg ` are present they are written.
488512
513+ It is ignored if the ` level ` of ` self ` is higher than ` error_level ` .
514+
489515#### Class
490516
491517Subroutine
@@ -569,6 +595,8 @@ If time stamps are active, a time stamp is written, followed
569595by ` module ` and ` procedure ` if present, and then
570596` message ` is written with the prefix ` 'INFO: ' ` .
571597
598+ It is ignored if the ` level ` of ` self ` is higher than ` information_level ` .
599+
572600#### Class
573601
574602Subroutine
@@ -637,6 +665,8 @@ written. Then `message` is written with the prefix
637665` 'I/O ERROR: ' ` . Then if ` iostat ` or ` iomsg ` are present they are
638666written.
639667
668+ It is ignored if the ` level ` of ` self ` is higher than ` io_error_level ` .
669+
640670#### Syntax
641671
642672` call self % [[logger_type(type):log_io_error(bound)]]( message [, module, procedure, iostat, iomsg ] ) `
@@ -714,6 +744,8 @@ If time stamps are active, a time stamp is written,
714744then ` module ` and ` procedure ` are written if present,
715745followed by ` prefix \\ ': ' ` , if present, and finally ` message ` .
716746
747+ No severity level is applied to ` log_message ` .
748+
717749#### Syntax
718750
719751` call self % [[logger_type(type):log_message(bound)]]( message [, module, procedure, prefix ] ) `
@@ -790,6 +822,8 @@ written with `column`. Then `line` is written. Then a caret, '^', is
790822written below ` line ` at the column indicated by ` column ` . Then
791823` summary ` is written below the caret.
792824
825+ It is ignored if the ` level ` of ` self ` is higher than ` text_error_level ` .
826+
793827#### Syntax
794828
795829` call self % [[logger_type(type):log_text_error(bound)]]( line, column, summary [, filename, line_number, caret, stat ] ) `
0 commit comments