@@ -8,19 +8,20 @@ title: logger
8
8
## Introduction
9
9
10
10
This 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
11
+ constants to be used for the reporting of errors, for filtering the
12
+ log messages, and other information. The derived type, ` logger_type ` ,
13
+ is to be used to define both global and local logger variables. The
14
+ ` logger_type ` methods serve to configure the loggers and use the logger
15
+ variables to report messages to a variable specific list of I/O units
16
+ termed ` log_units ` . The variable, ` global_logger ` , of type ` logger_type ` ,
17
+ is intended to serve as the default global logger. The constants serve as
18
18
error flags returned by the optional integer ` stat ` argument.
19
19
20
20
The logger variables have the option to:
21
21
22
22
* change which units receive the log messages;
23
23
* report which units receive the log messages;
24
+ * change the level for filtering the log messages;
24
25
* precede messages by a blank line;
25
26
* precede messages by a time stamp of the form
26
27
` yyyy-mm-dd hh:mm:ss.sss ` ;
@@ -64,6 +65,17 @@ Error Code | Description
64
65
` unopened_in_error ` | the unit was not opened
65
66
` write_fault ` | one of the writes to ` log_units ` failed
66
67
68
+ The module also defines eight distinct public integer constants for
69
+ filtering the log messages. These constants, termed severity levels, are
70
+ (sorted following their increasing order of severity): ` all_level ` ,
71
+ ` debug_level ` , ` information_level ` , ` warning_level ` , ` error_level ` ,
72
+ ` io_error_level ` , ` text_error_level ` , and ` none_level ` .
73
+ All log messages with a level lower than a specified severity level (e.g.,
74
+ ` information_level ` ) will be ignored. The levels ` error_level ` ,
75
+ ` io_error_level ` , and ` text_error_level ` have the same severity.
76
+ The default severity level is ` information_level ` .
77
+
78
+
67
79
## The derived type: logger_type
68
80
69
81
### Status
@@ -81,14 +93,15 @@ significant events encountered during the execution of a program.
81
93
82
94
### Private attributes
83
95
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 |
96
+ | Attribute | Type | Description | Initial value |
97
+ | ------------------| ---------------| -------------------------------------------------| ---------------------|
98
+ | ` add_blank_line ` | Logical | Flag to precede output with a blank line | ` .false. ` |
99
+ | ` indent_lines ` | Logical | Flag to indent subsequent lines by four columns | ` .true. ` |
100
+ | ` level ` | Integer | Severity level | ` information_level ` |
101
+ | ` log_units ` | Integer array | List of I/O units used for output | Unallocated |
102
+ | ` max_width ` | Integer | Maximum column width of output | 0 |
103
+ | ` time_stamp ` | Logical | Flag to precede output by a time stamp | ` .true. ` |
104
+ | ` units ` | Integer | Count of the number of active output units | 0 |
92
105
93
106
## The ` stdlib_logger ` variable
94
107
@@ -284,7 +297,7 @@ Reports the configuration of a logger.
284
297
285
298
#### Syntax
286
299
287
- ` call self % [[logger_type(type):configuration(bound)]]( [ add_blankline, indent, max_width, time_stamp, log_units ] ) `
300
+ ` call self % [[logger_type(type):configuration(bound)]]( [ add_blankline, indent, level, max_width, time_stamp, log_units ] ) `
288
301
289
302
#### Class
290
303
@@ -303,6 +316,10 @@ Pure subroutine
303
316
is an ` intent(out) ` argument. A value of ` .true. ` indents subsequent
304
317
lines by four spaces, and ` .false. ` otherwise.
305
318
319
+ ` level ` (optional): shall be a scalar default integer variable. It is an
320
+ ` intent(out) ` argument. The value corresponds to the severity level for
321
+ ignoring a message.
322
+
306
323
` max_width ` (optional): shall be a scalar default integer
307
324
variable. It is an ` intent(out) ` argument. A positive value bigger
308
325
than four defines the maximum width of the output, otherwise there
@@ -355,7 +372,7 @@ Configures the logging process for self.
355
372
356
373
#### Syntax
357
374
358
- ` call self % [[logger_type(type):configure(bound)]]( [ add_blank_line, indent, max_width, time_stamp ] ) `
375
+ ` call self % [[logger_type(type):configure(bound)]]( [ add_blank_line, indent, level, max_width, time_stamp ] ) `
359
376
360
377
#### Class
361
378
@@ -375,6 +392,10 @@ Pure subroutine
375
392
indent subsequent lines by four spaces, and to ` .false. ` to
376
393
not indent.
377
394
395
+ ` level ` (optional): shall be a scalar default integer expression. It is
396
+ an ` intent(in) ` argument. Set the severity level for ignoring a log
397
+ message.
398
+
378
399
` max_width ` (optional): shall be a scalar default integer
379
400
expression. It is an ` intent(in) ` argument. Set to a positive value
380
401
bigger than four to define the maximum width of the output,
@@ -416,6 +437,8 @@ If time stamps are active, a time stamp is written, followed
416
437
by ` module ` and ` procedure ` if present, and then
417
438
` message ` is written with the prefix ` 'DEBUG: ' ` .
418
439
440
+ It is ignored if the ` level ` of ` self ` is higher than ` debug_level ` .
441
+
419
442
#### Class
420
443
421
444
Subroutine
@@ -486,6 +509,8 @@ followed by `module` and `procedure` if present, then
486
509
` message ` is written with the prefix ` 'ERROR: ' ` , and then
487
510
if ` stat ` or ` errmsg ` are present they are written.
488
511
512
+ It is ignored if the ` level ` of ` self ` is higher than ` error_level ` .
513
+
489
514
#### Class
490
515
491
516
Subroutine
@@ -569,6 +594,8 @@ If time stamps are active, a time stamp is written, followed
569
594
by ` module ` and ` procedure ` if present, and then
570
595
` message ` is written with the prefix ` 'INFO: ' ` .
571
596
597
+ It is ignored if the ` level ` of ` self ` is higher than ` information_level ` .
598
+
572
599
#### Class
573
600
574
601
Subroutine
@@ -637,6 +664,8 @@ written. Then `message` is written with the prefix
637
664
` 'I/O ERROR: ' ` . Then if ` iostat ` or ` iomsg ` are present they are
638
665
written.
639
666
667
+ It is ignored if the ` level ` of ` self ` is higher than ` io_error_level ` .
668
+
640
669
#### Syntax
641
670
642
671
` call self % [[logger_type(type):log_io_error(bound)]]( message [, module, procedure, iostat, iomsg ] ) `
@@ -714,6 +743,8 @@ If time stamps are active, a time stamp is written,
714
743
then ` module ` and ` procedure ` are written if present,
715
744
followed by ` prefix \\ ': ' ` , if present, and finally ` message ` .
716
745
746
+ No severity level is applied to ` log_message ` .
747
+
717
748
#### Syntax
718
749
719
750
` call self % [[logger_type(type):log_message(bound)]]( message [, module, procedure, prefix ] ) `
@@ -790,6 +821,8 @@ written with `column`. Then `line` is written. Then a caret, '^', is
790
821
written below ` line ` at the column indicated by ` column ` . Then
791
822
` summary ` is written below the caret.
792
823
824
+ It is ignored if the ` level ` of ` self ` is higher than ` text_error_level ` .
825
+
793
826
#### Syntax
794
827
795
828
` call self % [[logger_type(type):log_text_error(bound)]]( line, column, summary [, filename, line_number, caret, stat ] ) `
0 commit comments