Skip to content

sschmid/Sherlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2fa502c · May 17, 2023

History

45 Commits
Mar 14, 2023
Sep 29, 2022
Oct 19, 2022
Nov 14, 2022
Nov 14, 2022
Nov 14, 2022
Sep 29, 2022
May 17, 2023
Sep 29, 2022
Nov 14, 2022
Nov 14, 2022
Oct 12, 2022
Oct 6, 2022
May 17, 2023
Oct 27, 2022
Sep 29, 2022
Oct 11, 2022

Repository files navigation

Sherlog-Header

Sherlog – Flexible logging for C# and Unity

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.

CI Coverage Status NuGet License: MIT Twitter

Install

NuGet Unity Packages on OpenUPM
Sherlog NuGet openupm
Sherlog.Appenders NuGet openupm
Sherlog.Formatters NuGet openupm

Automated Unity Package Releases: https://github.com/sschmid/com.sschmid.sherlog

Quick Start

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.

dotnet run --project samples/SherlogSamples/SherlogSamples.csproj

Run the SherlogServer project to receive the sample log messages from SherlogSamples via a TCP connection.

dotnet run --project samples/SherlogServer/SherlogServer.csproj listen 12345

SherlogSamples

Sherlog terminology

LogLevel

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.

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:

Formatters

Similar to appenders you can add formatters to decorate messages with additional info like logger name, log level, timestamp, or color.

Maintainer(s)

@sschmid on GitHub - @s_schmid on Twitter

About

Flexible logging for C# and Unity

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages