New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing for NONE
log level
#42
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0824dd4
Respect `NONE` logging level
boxleytw 5c20d87
Batect improvement
boxleytw c457118
Merge remote-tracking branch 'upstream/main'
boxleytw 72e2713
Remove dead code
boxleytw 817e381
PR feedback
boxleytw e866222
Merge from upstream
boxleytw File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,31 +34,41 @@ public interface Klogger : BaseLogger { | |
/** Emit an event after minimum level checking. */ | ||
public suspend fun emitEvent(level: Level, exception: Exception?, event: Any?) | ||
|
||
public suspend fun log(level: Level, exception: Exception, event: Any?): Unit = | ||
public suspend fun log(level: Level, exception: Exception, event: Any?) { | ||
if (!isLevelEnabled(level)) return | ||
emitEvent(level, exception, event) | ||
} | ||
|
||
public suspend fun log(level: Level, event: Any?): Unit = | ||
public suspend fun log(level: Level, event: Any?) { | ||
if (!isLevelEnabled(level)) return | ||
emitEvent(level, null, event) | ||
} | ||
|
||
public suspend fun log( | ||
level: Level, | ||
exception: Exception, | ||
template: String, | ||
vararg values: Any? | ||
): Unit = | ||
) { | ||
if (!isLevelEnabled(level)) return | ||
if (values.isEmpty()) emitEvent(level, exception, template) | ||
else emitEvent(level, exception, e(template, *values)) | ||
} | ||
|
||
public suspend fun log(level: Level, template: String, vararg values: Any?): Unit = | ||
public suspend fun log(level: Level, template: String, vararg values: Any?) { | ||
if (!isLevelEnabled(level)) return | ||
if (values.isEmpty()) emitEvent(level, null, template) | ||
else emitEvent(level, null, e(template, *values)) | ||
} | ||
|
||
public suspend fun log(level: Level, exception: Exception, event: suspend Klogger.() -> Any?) { | ||
if (isLevelEnabled(level)) emitEvent(level, exception, event()) | ||
if (!isLevelEnabled(level)) return | ||
emitEvent(level, exception, event()) | ||
} | ||
|
||
public suspend fun log(level: Level, event: suspend Klogger.() -> Any?) { | ||
if (isLevelEnabled(level)) emitEvent(level, null, event()) | ||
if (!isLevelEnabled(level)) return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
emitEvent(level, null, event()) | ||
} | ||
|
||
public suspend fun trace(event: Any?): Unit = log(TRACE, event) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original is clearer. An early return is only needed if what follows is more complex.
But I won’t go to the barricades over this. I can see the consistency with the earlier, more complex functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, two reasons: