This repository has been archived by the owner on Mar 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minor] Adds mechanism for having multiple logging targets
- Loading branch information
1 parent
6e9c3b3
commit d835616
Showing
6 changed files
with
97 additions
and
4 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package clog.impl | ||
|
||
import clog.Clog | ||
import clog.api.ClogLogger | ||
|
||
/** | ||
* Passes a log message to multiple other loggers | ||
*/ | ||
data class DelegatingLogger( | ||
val delegates: List<ClogLogger> = emptyList() | ||
) : ClogLogger { | ||
override fun log(priority: Clog.Priority, tag: String?, message: String) { | ||
delegates.forEach { it.log(priority, tag, message) } | ||
} | ||
|
||
/** | ||
* Returns a copy of this [DelegatingLogger] with [logger] appended to its list of [delegates]. | ||
*/ | ||
operator fun plus(logger: ClogLogger): DelegatingLogger { | ||
return DelegatingLogger( | ||
delegates + logger | ||
) | ||
} | ||
} |
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