Skip to content

Commit 478fe70

Browse files
committed
level_logger: addition of conditions
1 parent bde8ce8 commit 478fe70

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/stdlib_logger.f90

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,20 @@ module stdlib_logger
6969
write_failure = 8
7070

7171
integer, parameter, public :: &
72+
stdlib_all_level = 0, &
7273
stdlib_debug_level = 10, &
7374
stdlib_information_level = 20, &
7475
stdlib_warning_level = 30, &
7576
stdlib_error_level = 40, &
7677
stdlib_io_error_level = 40, &
77-
stdlib_text_error_level = 40
78-
78+
stdlib_text_error_level = 40, &
79+
stdlib_none_level = 10 + max( &
80+
stdlib_debug_level, &
81+
stdlib_information_level, &
82+
stdlib_warning_level, &
83+
stdlib_error_level, &
84+
stdlib_io_error_level, &
85+
stdlib_text_error_level)
7986

8087
character(*), parameter :: module_name = 'stdlib_logger'
8188

@@ -389,7 +396,7 @@ end subroutine validate_unit
389396
end subroutine add_log_unit
390397

391398

392-
pure subroutine configuration( self, add_blank_line, indent, &
399+
pure subroutine configuration( self, add_blank_line, indent, level, &
393400
max_width, time_stamp, log_units )
394401
!! version: experimental
395402

@@ -399,12 +406,13 @@ pure subroutine configuration( self, add_blank_line, indent, &
399406
!! starts with a blank line, and `.false.` implying no blank line.
400407
!! 2. `indent` is a logical flag with `.true.` implying that subsequent columns
401408
!! will be indented 4 spaces and `.false.` implying no indentation.
402-
!! 3. `max_width` is the maximum number of columns of output text with
409+
!! 3. `level` is the lowest level for printing a message
410+
!! 4. `max_width` is the maximum number of columns of output text with
403411
!! `max_width` == 0 => no bounds on output width.
404-
!! 4. `time_stamp` is a logical flag with `.true.` implying that the output
412+
!! 5. `time_stamp` is a logical flag with `.true.` implying that the output
405413
!! will have a time stamp, and `.false.` implying that there will be no
406414
!! time stamp.
407-
!! 5. `log_units` is an array of the I/O unit numbers to which log output
415+
!! 6. `log_units` is an array of the I/O unit numbers to which log output
408416
!! will be written.
409417
!!([Specification](../page/specs/stdlib_logger.html#configuration-report-a-loggers-configuration))
410418

@@ -414,6 +422,8 @@ pure subroutine configuration( self, add_blank_line, indent, &
414422
!! A logical flag to add a preceding blank line
415423
logical, intent(out), optional :: indent
416424
!! A logical flag to indent subsequent lines
425+
integer, intent(out), optional :: level
426+
!! The mimimum level for printing a message
417427
integer, intent(out), optional :: max_width
418428
!! The maximum number of columns for most outputs
419429
logical, intent(out), optional :: time_stamp
@@ -444,6 +454,7 @@ pure subroutine configuration( self, add_blank_line, indent, &
444454

445455
if ( present(add_blank_line) ) add_blank_line = self % add_blank_line
446456
if ( present(indent) ) indent = self % indent_lines
457+
if ( present(level) ) level = self % level
447458
if ( present(max_width) ) max_width = self % max_width
448459
if ( present(time_stamp) ) time_stamp = self % time_stamp
449460
if ( present(log_units) .and. self % units .gt. 0 ) then
@@ -455,7 +466,7 @@ pure subroutine configuration( self, add_blank_line, indent, &
455466
end subroutine configuration
456467

457468

458-
pure subroutine configure( self, add_blank_line, indent, max_width, &
469+
pure subroutine configure( self, add_blank_line, indent, level, max_width, &
459470
time_stamp )
460471
!! version: experimental
461472

@@ -467,10 +478,11 @@ pure subroutine configure( self, add_blank_line, indent, max_width, &
467478
!! 2. `indent` is a logical flag with `.true.` implying that subsequent lines
468479
!! will be indented 4 spaces and `.false.` implying no indentation. `indent`
469480
!! has a startup value of `.true.`.
470-
!! 3. `max_width` is the maximum number of columns of output text with
481+
!! 3. `level` is the lowest level for printing a message
482+
!! 4. `max_width` is the maximum number of columns of output text with
471483
!! `max_width == 0` => no bounds on output width. `max_width` has a startup
472484
!! value of 0.
473-
!! 4. `time_stamp` is a logical flag with `.true.` implying that the output
485+
!! 5. `time_stamp` is a logical flag with `.true.` implying that the output
474486
!! will have a time stamp, and `.false.` implying that there will be no
475487
!! time stamp. `time_stamp` has a startup value of `.true.`.
476488
!!([Specification](../page/specs/stdlib_logger.html#configure-configure-the-logging-process))
@@ -485,10 +497,12 @@ pure subroutine configure( self, add_blank_line, indent, max_width, &
485497
class(logger_type), intent(inout) :: self
486498
logical, intent(in), optional :: add_blank_line
487499
logical, intent(in), optional :: indent
500+
integer, intent(in), optional :: level
488501
integer, intent(in), optional :: max_width
489502
logical, intent(in), optional :: time_stamp
490503

491504
if ( present(add_blank_line) ) self % add_blank_line = add_blank_line
505+
if ( present(level) ) self % level = level
492506
if ( present(indent) ) self % indent_lines = indent
493507
if ( present(max_width) ) then
494508
if ( max_width <= 4 ) then

0 commit comments

Comments
 (0)