Sherlog is a very light logging library with a clear focus on speed, flexibility, and extensibility. It supports local and remote logging out of the box so you can receive log messages from other devices over the air.
NuGet | Unity Packages on OpenUPM | |
---|---|---|
Sherlog | ||
Sherlog.Appenders | ||
Sherlog.Formatters |
Automated Unity Package Releases: https://github.com/sschmid/com.sschmid.sherlog
The SherlogSamples project contains samples for different use cases, such as logging to the console, adding colors or timestamps, and sending log messages via TCP to other devices.
See SherlogSamples
dotnet run --project samples/SherlogSamples/SherlogSamples.csproj
Run the SherlogServer project to receive the sample log messages from SherlogSamples via a TCP connection.
See SherlogServer
dotnet run --project samples/SherlogServer/SherlogServer.csproj listen 12345
There are 6 log levels matching the Sherlog log methods:
logger.Trace("This is a message using logger.Trace()");
logger.Debug("This is a message using logger.Debug()");
logger.Info("This is a message using logger.Info()");
logger.Warn("This is a message using logger.Warn()");
logger.Error("This is a message using logger.Error()");
logger.Fatal("This is a message using logger.Fatal()");
You can set the log level per logger or globally for all existing and future loggers.
Logger.GlobalLogLevel = LogLevel.Warn;
var logger = Logger.GetLogger("MyLogger");
logger.LogLevel = LogLevel.Debug;
Only log methods that match or exceed the current log level will forward messages to appenders.
Sherlog's plugin architecture lets you add multiple different appenders to handle log messages. An appender is a delegate method which contains the logic for processing log messages. It might write a message to a file, print it to the console or send it over the network via TCP. You can easily write your own appenders. There are no limits!
Sherlog comes with a handful of pre-made appenders and helper classes to get you started quickly:
Similar to appenders you can add formatters to decorate messages with additional info like logger name, log level, timestamp, or color.