public final class DefaultLoggingService extends java.lang.Object implements LoggingService
Default implementation of the logging service for stream agents. It logs the data to the SLF4J logger named “stream”.
Each log file entry consists of an entry type tag and entry values, each separated with a semicolon delimiter (**;**).
The supported log entry types are as follows: - [PD]
- log entry with a one-line problem definition string - [WH]
- log entry with a one-line definition of properties used in the workplace entries - [SH]
- log entry with a one-line definition of properties used in the tick summary entries - [BH]
- log entry with a one-line definition of properties used in best solution entries - [W]
- log entry for a particular workplace in a tick (each tick consist of n such entries, if n is the number of all workplaces) - [S]
- log entry with a tick summary (each tick consists of exactly one entry of this type) - [B]
- log entry with the best solution (there might be more than one entry of this type in a log, if multiple agents can have the same evaluation)
Log entries appear in the log file in the order same as defined above. There is only one log entry for each of types {[PD]
, [WH]
, [SH]
, [BH]
} and one or more entries for the rest of the types.
Modifier and Type | Field and Description |
---|---|
private AgentsRegistry<? extends Agent> |
agentsRegistry |
static java.lang.String |
DELIMITER |
private EvaluatorCounter |
evaluatorCounter |
private boolean |
headerLogged |
private static org.slf4j.Logger |
logger |
private @Nullable ListenableScheduledFuture<?> |
loggerFuture |
private LoggingParameters |
parameters |
private long |
startTime |
private static org.slf4j.Logger |
stream_logger |
Constructor and Description |
---|
DefaultLoggingService(LoggingParameters parameters,
EvaluatorCounter evaluatorCounter,
AgentsRegistry<? extends Agent> agentsRegistry) |
Modifier and Type | Method and Description |
---|---|
private static void |
logBestSolutionHeader() |
private static void |
logBestSolutions(io.vavr.collection.Map<java.lang.String,io.vavr.Tuple3<java.lang.Long,java.lang.Long,java.lang.Long>> solutionsMap) |
private void |
logHeaders(io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> statistics) |
private void |
logProblemDefinition(ProblemDefinition problemDefinition) |
private void |
logStatistics(io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> statistics,
int workplacesCount) |
private static void |
logSummaryHeader() |
private void |
logSummaryStatistics(java.lang.Long time) |
private static void |
logWorkplaceHeader(io.vavr.collection.Map<java.lang.Object,java.lang.Object> workplaceStats) |
private void |
logWorkplaceStatistics(java.lang.Long time,
java.lang.Long workplaceId,
int workplacesCount,
io.vavr.collection.Map<java.lang.Object,java.lang.Object> workplaceStats) |
void |
schedule(Manager statisticsManager,
ThreadPool threadPool)
Schedules and starts this service in the provided
ThreadPool |
void |
stop()
Stops this service
|
private static final org.slf4j.Logger logger
private static final org.slf4j.Logger stream_logger
public static final java.lang.String DELIMITER
private final LoggingParameters parameters
private final EvaluatorCounter evaluatorCounter
private final AgentsRegistry<? extends Agent> agentsRegistry
private boolean headerLogged
private long startTime
private @Nullable ListenableScheduledFuture<?> loggerFuture
@Inject public DefaultLoggingService(LoggingParameters parameters, EvaluatorCounter evaluatorCounter, AgentsRegistry<? extends Agent> agentsRegistry)
public void schedule(Manager statisticsManager, ThreadPool threadPool)
LoggingService
Schedules and starts this service in the provided ThreadPool
Statistics will be obtained by this service from the passes Manager
.
schedule
in interface LoggingService
statisticsManager
- provider of the statisticsthreadPool
- thread pool used to schedule the servicejava.lang.IllegalStateException
- if this service was already scheduledpublic void stop()
LoggingService
Stops this service
This operations does not have to be synchronous. Service may be stopped some time in the future after this call.
stop
in interface LoggingService
java.lang.IllegalStateException
- if this service was not yet scheduledprivate void logProblemDefinition(ProblemDefinition problemDefinition)
private void logStatistics(io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> statistics, int workplacesCount)
private void logWorkplaceStatistics(java.lang.Long time, java.lang.Long workplaceId, int workplacesCount, io.vavr.collection.Map<java.lang.Object,java.lang.Object> workplaceStats)
private void logSummaryStatistics(java.lang.Long time)
private static void logBestSolutions(io.vavr.collection.Map<java.lang.String,io.vavr.Tuple3<java.lang.Long,java.lang.Long,java.lang.Long>> solutionsMap)
private void logHeaders(io.vavr.collection.Map<java.lang.Long,io.vavr.collection.Map<java.lang.Object,java.lang.Object>> statistics)
private static void logWorkplaceHeader(io.vavr.collection.Map<java.lang.Object,java.lang.Object> workplaceStats)
private static void logSummaryHeader()
private static void logBestSolutionHeader()