Skip to content

Commit 797f59f

Browse files
authored
Merge pull request #255 from jvdp1/logger_fix
Fix for a small issue in stdlib_logger
2 parents e54f92a + 848c52f commit 797f59f

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

src/stdlib_logger.f90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,12 @@ pure subroutine configuration( self, add_blank_line, indent, &
435435
if ( present(indent) ) indent = self % indent_lines
436436
if ( present(max_width) ) max_width = self % max_width
437437
if ( present(time_stamp) ) time_stamp = self % time_stamp
438-
if ( present(log_units) .and. self % units .gt. 0 ) then
439-
log_units = self % log_units(1:self % units)
440-
else
441-
allocate(log_units(0))
438+
if ( present(log_units) ) then
439+
if ( self % units .gt. 0 ) then
440+
log_units = self % log_units(1:self % units)
441+
else
442+
allocate(log_units(0))
443+
end if
442444
end if
443445

444446
end subroutine configuration

src/tests/logger/test_stdlib_logger.f90

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,62 @@ subroutine test_logging_configuration()
126126

127127
end if
128128

129+
!testing all calls independently
130+
call global % configuration( add_blank_line=add_blank_line )
131+
132+
if ( .not. add_blank_line ) then
133+
write(*,*) 'ADD_BLANK_LINE starts off as .FALSE. as expected.'
134+
135+
else
136+
error stop 'ADD_BLANK_LINE starts off as .TRUE. contrary to ' // &
137+
'expectations.'
138+
139+
end if
140+
141+
call global % configuration( indent=indent )
142+
143+
if ( indent ) then
144+
write(*,*) 'INDENT starts off as .TRUE. as expected.'
145+
146+
else
147+
error stop 'INDENT starts off as .FALSE. contrary to expectations.'
148+
149+
end if
150+
151+
call global % configuration( max_width=max_width )
152+
153+
if ( max_width == 0 ) then
154+
write(*,*) 'MAX_WIDTH starts off as 0 as expected.'
155+
156+
else
157+
error stop 'MAX_WIDTH starts off as not equal to 0 contrary ' // &
158+
'to expectations.'
159+
160+
end if
161+
162+
call global % configuration( time_stamp=time_stamp )
163+
164+
if ( time_stamp ) then
165+
write(*,*) 'TIME_STAMP starts off as .TRUE. as expected.'
166+
167+
else
168+
error stop 'TIME_STAMP starts off as .FALSE. contrary to ' // &
169+
'expectations.'
170+
171+
end if
172+
173+
call global % configuration( log_units=log_units )
174+
175+
if ( size(log_units) == 0 ) then
176+
write(*,*) 'SIZE(LOG_UNITS) starts off as 0 as expected.'
177+
178+
else
179+
error stop 'SIZE(LOG_UNITS) starts off as non-zero contrary ' // &
180+
'to expectations.'
181+
182+
end if
183+
184+
129185
call global % log_information( 'This message should be output ' // &
130186
'to OUTPUT_UNIT, unlimited in width, not preceded by ' // &
131187
'a blank line, then by a time stamp, then by MODULE % ' // &

0 commit comments

Comments
 (0)