@@ -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
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.
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
+ * select which types of messages are logged;
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,18 @@ 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
+ 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
+
67
80
## The derived type: logger_type
68
81
69
82
### Status
@@ -81,14 +94,15 @@ significant events encountered during the execution of a program.
81
94
82
95
### Private attributes
83
96
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 |
92
106
93
107
## The ` stdlib_logger ` variable
94
108
@@ -284,7 +298,7 @@ Reports the configuration of a logger.
284
298
285
299
#### Syntax
286
300
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 ] ) `
288
302
289
303
#### Class
290
304
@@ -303,6 +317,10 @@ Pure subroutine
303
317
is an ` intent(out) ` argument. A value of ` .true. ` indents subsequent
304
318
lines by four spaces, and ` .false. ` otherwise.
305
319
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
+
306
324
` max_width ` (optional): shall be a scalar default integer
307
325
variable. It is an ` intent(out) ` argument. A positive value bigger
308
326
than four defines the maximum width of the output, otherwise there
@@ -355,7 +373,7 @@ Configures the logging process for self.
355
373
356
374
#### Syntax
357
375
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 ] ) `
359
377
360
378
#### Class
361
379
@@ -375,6 +393,10 @@ Pure subroutine
375
393
indent subsequent lines by four spaces, and to ` .false. ` to
376
394
not indent.
377
395
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
+
378
400
` max_width ` (optional): shall be a scalar default integer
379
401
expression. It is an ` intent(in) ` argument. Set to a positive value
380
402
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
416
438
by ` module ` and ` procedure ` if present, and then
417
439
` message ` is written with the prefix ` 'DEBUG: ' ` .
418
440
441
+ It is ignored if the ` level ` of ` self ` is higher than ` debug_level ` .
442
+
419
443
#### Class
420
444
421
445
Subroutine
@@ -486,6 +510,8 @@ followed by `module` and `procedure` if present, then
486
510
` message ` is written with the prefix ` 'ERROR: ' ` , and then
487
511
if ` stat ` or ` errmsg ` are present they are written.
488
512
513
+ It is ignored if the ` level ` of ` self ` is higher than ` error_level ` .
514
+
489
515
#### Class
490
516
491
517
Subroutine
@@ -569,6 +595,8 @@ If time stamps are active, a time stamp is written, followed
569
595
by ` module ` and ` procedure ` if present, and then
570
596
` message ` is written with the prefix ` 'INFO: ' ` .
571
597
598
+ It is ignored if the ` level ` of ` self ` is higher than ` information_level ` .
599
+
572
600
#### Class
573
601
574
602
Subroutine
@@ -637,6 +665,8 @@ written. Then `message` is written with the prefix
637
665
` 'I/O ERROR: ' ` . Then if ` iostat ` or ` iomsg ` are present they are
638
666
written.
639
667
668
+ It is ignored if the ` level ` of ` self ` is higher than ` io_error_level ` .
669
+
640
670
#### Syntax
641
671
642
672
` 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,
714
744
then ` module ` and ` procedure ` are written if present,
715
745
followed by ` prefix \\ ': ' ` , if present, and finally ` message ` .
716
746
747
+ No severity level is applied to ` log_message ` .
748
+
717
749
#### Syntax
718
750
719
751
` 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
790
822
written below ` line ` at the column indicated by ` column ` . Then
791
823
` summary ` is written below the caret.
792
824
825
+ It is ignored if the ` level ` of ` self ` is higher than ` text_error_level ` .
826
+
793
827
#### Syntax
794
828
795
829
` call self % [[logger_type(type):log_text_error(bound)]]( line, column, summary [, filename, line_number, caret, stat ] ) `
0 commit comments