Skip to content

Commit 479f582

Browse files
authored
Merge pull request #245 from wclodius2/logger-safe-async-io
Logger safe async io
2 parents 917adb9 + e5bc47f commit 479f582

File tree

4 files changed

+303
-217
lines changed

4 files changed

+303
-217
lines changed

doc/specs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This is and index/directory of the specifications (specs) for each new module/fe
1515
- [error](./stdlib_error.html) - Catching and handling errors
1616
- [IO](./stdlib_io.html) - Input/output helper & convenience
1717
- [linalg](./stdlib_linalg.html) - Linear Algebra
18+
- [logger](./stdlib_logger.html) - Runtime logging system
1819
- [optval](./stdlib_optval.html) - Fallback value for optional arguments
1920
- [quadrature](./stdlib_quadrature.html) - Numerical integration
2021
- [stats](./stdlib_stats.html) - Descriptive Statistics

doc/specs/stdlib_logger.md

+41-23
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ The logger variables have the option to:
3434
* indent subsequent lines of the messages; and
3535
* format the text to fit within a maximum column width.
3636

37+
While every effort has been made to make the code process and
38+
asynchronous I/O safe, it is always best to have each process write to
39+
its own dedicated logger file.
40+
For thread parallelism (e.g., with OpenMP), it is advised to put the
41+
logger call in a guarding region (e.g., in an OpenMP critical region).
42+
3743
Note: Loggers of type `logger_type` normally report their messages to I/O
3844
units in the internal list termed `log_units`. However if `log_units`
3945
is empty then the messages go to the `output_unit` of the intrinsic
@@ -75,14 +81,16 @@ significant events encountered during the execution of a program.
7581

7682
### Private attributes
7783

78-
| Attribute | Type | Description | Initial value
79-
|------------------|---------------|-------------------------------------------------|--------------
80-
| `add_blank_line` | Logical | Flag to precede output with a blank line | `.false.`
81-
| `indent_lines` | Logical | Flag to indent subsequent lines by four columns | `.true.`
82-
| `log_units` | Integer array | List of I/O units used for output | empty
83-
| `max_width` | Integer | Maximum column width of output | 0
84-
| `time_stamp` | Logical | Flag to precede output by a time stamp | `.true.`
85-
| `units` | Integer | Count of the number of active output units | 0
84+
| Attribute | Type | Description | Initial value |
85+
|------------------|---------------|-------------------------------------------------|--------------|
86+
| `add_blank_line` | Logical | Flag to precede output with a blank line | `.false.` |
87+
| `buffer` | Character(:) | Buffer to build output string | Unallocated |
88+
| `indent_lines` | Logical | Flag to indent subsequent lines by four columns | `.true.` |
89+
| `len_buffer` | Integer | Number of valid characters in buffer | 0 |
90+
| `log_units` | Integer array | List of I/O units used for output | Unallocated |
91+
| `max_width` | Integer | Maximum column width of output | 0 |
92+
| `time_stamp` | Logical | Flag to precede output by a time stamp | `.true.` |
93+
| `units` | Integer | Count of the number of active output units | 0 |
8694

8795
## The `stdlib_logger` variable
8896

@@ -285,7 +293,7 @@ Pure subroutine
285293

286294
#### Arguments
287295

288-
`self`: shall be a scalar variable of type `logger_type`. It is an
296+
`self`: shall be a scalar expression of type `logger_type`. It is an
289297
`intent(in)` argument. It shall be the logger whose configuration is reported.
290298

291299
`add_blank_line` (optional): shall be a scalar default logical
@@ -416,11 +424,13 @@ Subroutine
416424

417425
#### Arguments
418426

419-
`self`: shall be a scalar expression of type `logger_type`. It is an
420-
`intent(in)` argument. It is the logger used to send the message.
427+
`self`: shall be a scalar variable of type `logger_type`. It is an
428+
`intent(inout)` argument. It is the logger used to send the message.
421429

422430
`message`: shall be a scalar default character expression. It is an
423-
`intent(in)` argument.
431+
`intent(in)` argument.
432+
433+
* Note `message` may have embedded new_line calls.
424434

425435
`module` (optional): shall be a scalar default character
426436
expression. It is an `intent(in)` argument. It should be the name of
@@ -497,12 +507,14 @@ Subroutine
497507

498508
#### Arguments
499509

500-
`self`: shall be a scalar expression of type `logger_type`. It is an
501-
`intent(in)` argument. It is the logger used to send the message.
510+
`self`: shall be a scalar variable of type `logger_type`. It is an
511+
`intent(inout)` argument. It is the logger used to send the message.
502512

503513
`message`: shall be a scalar default character expression. It is an
504514
`intent(in)` argument.
505515

516+
* Note `message` may have embedded new_line calls.
517+
506518
`module` (optional): shall be a scalar default character
507519
expression. It is an `intent(in)` argument. It should be the name of
508520
the module containing the `log_information` call.
@@ -566,12 +578,14 @@ written.
566578
Subroutine
567579

568580
#### Arguments
569-
`self`: shall be a scalar expression of type `logger_type`. It is an
570-
`intent(in)` argument. It is the logger used to send the message.
581+
`self`: shall be a scalar variable of type `logger_type`. It is an
582+
`intent(inout)` argument. It is the logger used to send the message.
571583

572584
`message`: shall be a scalar default character expression. It is an
573585
`intent(in)` argument.
574586

587+
* Note `message` may have embedded new_line calls.
588+
575589
`module` (optional): shall be a scalar default character
576590
expression. It is an `intent(in)` argument. It should be the name of
577591
the module containing the `log_io_error` call.
@@ -642,12 +656,14 @@ Subroutine
642656

643657
#### Arguments
644658

645-
`self`: shall be a scalar expression of type `logger_type`. It is an
646-
`intent(in)` argument. It is the logger used to send the message.
659+
`self`: shall be a scalar variable of type `logger_type`. It is an
660+
`intent(inout)` argument. It is the logger used to send the message.
647661

648662
`message`: shall be a scalar default character expression. It is an
649663
`intent(in)` argument.
650664

665+
* Note `message` may have embedded new_line calls.
666+
651667
`module` (optional): shall be a scalar default character
652668
expression. It is an `intent(in)` argument. It should be the name of
653669
the module containing the `log_message` call.
@@ -716,8 +732,8 @@ Subroutine
716732

717733
#### Arguments
718734

719-
`self`: shall be a scalar expression of type `logger_type`. It is an
720-
`intent(in)` argument. It is the logger used to send the message.
735+
`self`: shall be a scalar variable of type `logger_type`. It is an
736+
`intent(inout)` argument. It is the logger used to send the message.
721737

722738
`line`: shall be a scalar default character expression. It is an
723739
`intent(in)` argument. It should be the line of text in which the
@@ -862,12 +878,14 @@ Subroutine
862878

863879
#### Arguments
864880

865-
`self`: shall be a scalar expression of type `logger_type`. It is an
866-
`intent(in)` argument. It is the logger used to send the message.
881+
`self`: shall be a scalar variable of type `logger_type`. It is an
882+
`intent(inout)` argument. It is the logger used to send the message.
867883

868884
`message`: shall be a scalar default character expression. It is an
869885
`intent(in)` argument.
870886

887+
* Note `message` may have embedded new_line calls.
888+
871889
`module`: (optional) shall be a scalar default character
872890
expression. It is an `intent(in)` argument. It should be the name of
873891
the module containing the `log_warning` call.
@@ -925,7 +943,7 @@ Subroutine
925943

926944
#### Arguments
927945

928-
`self`: shall be a scalar expression of type `logger_type`. It is an
946+
`self`: shall be a scalar variable of type `logger_type`. It is an
929947
`intent(inout)` argument. It is the logger whose `log_units` is to be
930948
modified.
931949

0 commit comments

Comments
 (0)