Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Mar 16, 2020
2 parents 3864d01 + af8d35e commit b6ee610
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<!--
git log --pretty="* %s ([%h](https://github.com/jecisc/TinyLogger/commit/%H))" v1.1.4...HEAD --grep="Merge pull"
git log --pretty="* %s ([%h](https://github.com/jecisc/TinyLogger/commit/%H))" v1.1.5...HEAD --grep="Merge pull"
('Content' copyWithRegex: 'Merge pull request #[0-9]+ from [^/]+/[0-9]*' matchesReplacedWith: '') copyReplaceAll: '-' with: ' '
-->

# [v1.1.5](https://github.com/jecisc/TinyLogger/compare/v1.1.4...v1.1.5) (2020-03-16)

* Manage errors inside action logging ([172a181](https://github.com/jecisc/TinyLogger/commit/172a1818df984b08b1ab6ebe60646c0aaf160771))

# [v1.1.4](https://github.com/jecisc/TinyLogger/compare/v1.1.3...v1.1.4) (2019-11-15)

## Bug fix
Expand Down
31 changes: 31 additions & 0 deletions src/TinyLogger-Tests/TinyLoggerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,37 @@ No time : End: This is a new test
stream close ]
]

{ #category : #test }
TinyLoggerTest >> testExecuteRecordedAsKeepRightIndentation [
| contents stream |
self skipInPharo6.
logger
timestampFormatBlock: [ :s | s nextPutAll: 'No time' ];
removeAllLoggers;
addStdoutLogger.
stream := '' writeStream.
[ Stdio stub stdout willReturn: stream.
TinyCurrentLogger
value: logger
during: [ [ Object new execute: [ Error signal ] recordedAs: 'This is a new test' ]
on: Error
do: [ "nothing" ].
Object new execute: [ 'test' record ] recordedAs: 'This is a new test' ].
contents := Stdio stdout contents asString.
"Ensure we have the right indentation."
self
assert: contents withUnixLineEndings
equals:
'No time : Begin: This is a new test
No time : End with error: This is a new test
No time : Begin: This is a new test
No time : test
No time : End: This is a new test
' withUnixLineEndings ]
ensure: [ Stdio recoverFromGHMutation.
stream close ]
]

{ #category : #test }
TinyLoggerTest >> testFileLoggers [
logger
Expand Down
6 changes: 5 additions & 1 deletion src/TinyLogger/TinyLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ TinyLogger >> execute: aBlock recordedAs: aString [
self increaseDepthLevel.
self record: 'Begin: ' , aString.
self increaseDepthLevel.
aBlock cull: aString.
[ aBlock cull: aString ]
ifCurtailed: [ "If there is an error, we ensure we keep the right indentation and we print an end of action with error."
self decreaseDepthLevel.
self record: 'End with error: ' , aString.
self decreaseDepthLevel ].
self decreaseDepthLevel.
self record: 'End: ' , aString.
self decreaseDepthLevel
Expand Down

0 comments on commit b6ee610

Please sign in to comment.