-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add log
(based on slf4j) operator
#41
Comments
To consider: implement as |
Some questions/discussion starters:
enum LogLevel:
case Trace, Debug, Info, Warn, Error
def log(name: String, level: LogLevel = LogLevel.Info, formatter: T => String = _.toString)(using Ox, StageCapacity): Source[T] =
val logger = org.slf4j.LoggerFactory.getLogger(name)
map(t => { logF(logger, level)(formatter(t)); t })
def logAsView(name: String, level: LogLevel = LogLevel.Info, formatter: T => String = _.toString)(using Ox, StageCapacity): Source[T] =
val logger = org.slf4j.LoggerFactory.getLogger(name)
mapAsView(t => { logF(logger, level)(formatter(t)); t })
private def logF(logger: org.slf4j.Logger, level: LogLevel): String => Unit =
level match
case LogLevel.Trace => logger.trace
case LogLevel.Debug => logger.debug
case LogLevel.Info => logger.info
case LogLevel.Warn => logger.warn
case LogLevel.Error => logger.error |
To be honest I don't like neither of the options in 1., maybe since we already have |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: