In C#, the
ILogger
interface from Microsoft.Extensions.Logging.Abstractions is used for
logging. This means that
pipeline builders and
element builders should be supplied with an implementation of
ILoggerFactory
which will create
logger instances for each
Pipeline and
flow element they create.
Loggers will also be created for all
flow data and
element data that are created.
The simplest way is to create the default Microsoft implementation available in Microsoft.Extensions.Logging:
ILoggerFactory loggerFactory = new LoggerFactory();
In an ASP.NET Core environment, a logger can be introduced via dependency injection when starting up the service. This will then be injected into the pipeline builder.
In Java, the
Logger
interface from org.slf4j.slf4j-api is used for
logging. This means that
pipeline builders and
element builders should be supplied with an implementation of
ILoggerFactory
which will create
logger instances for each
Pipeline and
flow element that are created.
The easiest way is to include a dependency on an implementation of slf4j-api such as org.slf4j.slf4j-simple:
<project>
...
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j-simple.version}</version>
</dependency>
...
</dependencies>
...
</project>
This will then be injected automatically when creating builders using their default constructors.
Alternatively, an implementation can be passed explicitly in a builder's constructor:
PipelineBuilder builder = new PipelineBuilder(new MyLoggerFactory());
In node.js a Pipeline has an instance of an eventEmitter inside it which can be used to listen to events, logs and errors.
// Build the pipeline using an instance of the PipelineBuilder class
// Then, to monitor the pipeline we can put in listeners for various log events.
// Valid types are info, debug, warn, error
pipeline.on('error', console.error);
The PHP pipeline implementation includes a Logger class that can be used to record events that take place in the pipeline.
Here is an example of a basic logger that stores its logs in an array.
The log object passed to the overriden logInternal function is an associative array that contains:
- time - Y-m-d H:i:s format timestamp
- level - one of "trace", "debug", "information", "warning", "error", "critical"
- message - the message
use fiftyone[Pipeline](@ref Concepts_Pipeline)\core\Logger;
class MemoryLogger extends Logger
{
public $log = [];
public function logInternal($log)
{
$this->log[] = $log;
}
}
After making a logging class, you would then use this in a Pipeline as follows:
use fiftyone[Pipeline](@ref Concepts_Pipeline)\core\PipelineBuilder;
$logger = new MemoryLogger("info");
$pipelineBuilder = new PipelineBuilder();
$pipelineBuilder->addLogger($this->logger);
The python pipeline implementation includes a Logger class that can be used to record events that take place in the pipeline.
Here is an example of a basic logger that stores its logs in a list.
The log object passed to the overriden log_internal function is a dictionary that contains:
- time - Y-m-d H:i:s format timestamp
- level - one of "trace", "debug", "information", "warning", "error", "critical"
- message - the message
from fiftyone_pipeline_core.logger import Logger
class MemoryLogger(Logger):
def __init__(self, min_level="error", settings = {}):
super(MemoryLogger, self).__init__(min_level, settings)
self.memory_log = []
def log_internal(self, level, log):
self.memory_log.append(log)
After making a logging class, you would then use this in a Pipeline by using it in the PipelineBuilder when making your pipeline:
from fiftyone_pipeline_core.pipelinebuilder import PipelineBuilder
logger = MemoryLogger('info') // Pass in the minimum log level to the constructor
pipeline = (PipelineBuilder())\
.add_logger(logger)\
.build()