Class Recorder
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.log.Recorder
-
public class Recorder extends java.lang.ObjectLogs recorder. Applies custom appender for logback logger(s) and change level, if required. Collect all log events.- Since:
- 26.02.2025
-
-
Constructor Summary
Constructors Constructor Description Recorder(java.lang.String name, org.slf4j.event.Level level, java.util.List<java.lang.String> loggers)Create recorder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattach()Could be called multiple times.voidclear()Clear recordings.voiddestroy()Remove appender from logger.RecordedLogsgetRecordedLogs()Note that object always returns actual logs.java.util.List<ch.qos.logback.classic.spi.ILoggingEvent>getRecords()
-
-
-
Method Detail
-
getRecords
public java.util.List<ch.qos.logback.classic.spi.ILoggingEvent> getRecords()
- Returns:
- raw recorded records
- See Also:
for easy navigation
-
getRecordedLogs
public RecordedLogs getRecordedLogs()
Note that object always returns actual logs. So the same instance could be used to all verifications.- Returns:
- recorded logs navigation object
-
clear
public void clear()
Clear recordings.
-
attach
public void attach()
Could be called multiple times. Initially called before application start to record all startup events. But dropwizard reset loggers just before run phase, so appender must be applied second time.DON'T call this method manually: simply no need - hook will call it in appropriate moments.
-
destroy
public void destroy()
Remove appender from logger.Not required as dropwizard reset all logging during application startup and so stale appenders would be removed in any case before each new test.
-
-