Add log() in stream-error.md (#24522)
* Add log() in stream-error.md (#23722)
This commit is contained in:
parent
cb048457c8
commit
b3a27d1c9f
4 changed files with 59 additions and 10 deletions
|
|
@ -30,7 +30,13 @@ class RecipeLoggingElements extends RecipeSpec {
|
|||
//#log-custom
|
||||
// customise log levels
|
||||
mySource.log("before-map")
|
||||
.withAttributes(Attributes.logLevels(onElement = Logging.WarningLevel))
|
||||
.withAttributes(
|
||||
Attributes.logLevels(
|
||||
onElement = Logging.WarningLevel,
|
||||
onFinish = Logging.InfoLevel,
|
||||
onFailure = Logging.DebugLevel
|
||||
)
|
||||
)
|
||||
.map(analyse)
|
||||
|
||||
// or provide custom logging adapter
|
||||
|
|
@ -42,9 +48,16 @@ class RecipeLoggingElements extends RecipeSpec {
|
|||
EventFilter.debug(start = "[custom] Element: ").intercept {
|
||||
loggedSource.runWith(Sink.ignore)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"use log() for error logging" in {
|
||||
//#log-error
|
||||
Source(-5 to 5)
|
||||
.map(1 / _) //throwing ArithmeticException: / by zero
|
||||
.log("error logging")
|
||||
.runWith(Sink.ignore)
|
||||
//#log-error
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue