Skip to content

Commit b6ee610

Browse files
committed
Merge branch 'development'
2 parents 3864d01 + af8d35e commit b6ee610

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<!--
2-
git log --pretty="* %s ([%h](https://github.com/jecisc/TinyLogger/commit/%H))" v1.1.4...HEAD --grep="Merge pull"
2+
git log --pretty="* %s ([%h](https://github.com/jecisc/TinyLogger/commit/%H))" v1.1.5...HEAD --grep="Merge pull"
33
('Content' copyWithRegex: 'Merge pull request #[0-9]+ from [^/]+/[0-9]*' matchesReplacedWith: '') copyReplaceAll: '-' with: ' '
44
-->
55

6+
# [v1.1.5](https://github.com/jecisc/TinyLogger/compare/v1.1.4...v1.1.5) (2020-03-16)
7+
8+
* Manage errors inside action logging ([172a181](https://github.com/jecisc/TinyLogger/commit/172a1818df984b08b1ab6ebe60646c0aaf160771))
9+
610
# [v1.1.4](https://github.com/jecisc/TinyLogger/compare/v1.1.3...v1.1.4) (2019-11-15)
711

812
## Bug fix

src/TinyLogger-Tests/TinyLoggerTest.class.st

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,37 @@ No time : End: This is a new test
191191
stream close ]
192192
]
193193

194+
{ #category : #test }
195+
TinyLoggerTest >> testExecuteRecordedAsKeepRightIndentation [
196+
| contents stream |
197+
self skipInPharo6.
198+
logger
199+
timestampFormatBlock: [ :s | s nextPutAll: 'No time' ];
200+
removeAllLoggers;
201+
addStdoutLogger.
202+
stream := '' writeStream.
203+
[ Stdio stub stdout willReturn: stream.
204+
TinyCurrentLogger
205+
value: logger
206+
during: [ [ Object new execute: [ Error signal ] recordedAs: 'This is a new test' ]
207+
on: Error
208+
do: [ "nothing" ].
209+
Object new execute: [ 'test' record ] recordedAs: 'This is a new test' ].
210+
contents := Stdio stdout contents asString.
211+
"Ensure we have the right indentation."
212+
self
213+
assert: contents withUnixLineEndings
214+
equals:
215+
'No time : Begin: This is a new test
216+
No time : End with error: This is a new test
217+
No time : Begin: This is a new test
218+
No time : test
219+
No time : End: This is a new test
220+
' withUnixLineEndings ]
221+
ensure: [ Stdio recoverFromGHMutation.
222+
stream close ]
223+
]
224+
194225
{ #category : #test }
195226
TinyLoggerTest >> testFileLoggers [
196227
logger

src/TinyLogger/TinyLogger.class.st

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ TinyLogger >> execute: aBlock recordedAs: aString [
184184
self increaseDepthLevel.
185185
self record: 'Begin: ' , aString.
186186
self increaseDepthLevel.
187-
aBlock cull: aString.
187+
[ aBlock cull: aString ]
188+
ifCurtailed: [ "If there is an error, we ensure we keep the right indentation and we print an end of action with error."
189+
self decreaseDepthLevel.
190+
self record: 'End with error: ' , aString.
191+
self decreaseDepthLevel ].
188192
self decreaseDepthLevel.
189193
self record: 'End: ' , aString.
190194
self decreaseDepthLevel

0 commit comments

Comments
 (0)