Skip to content

BindOpen.Logging offers a simple and multidimensional logging system, perfect to monitor nested task executions.

License

Notifications You must be signed in to change notification settings

bindopen/BindOpen.Logging

Repository files navigation

BindOpen.Logging

BindOpen logo

Github release version

BindOpen is a framework that enables the development of highly extensible applications. It allows you to enhance your .NET projects with custom script functions, connectors, entities, and tasks.

About

BindOpen.Logging offers a simple and multidimensional logging system, perfect to monitor nested task executions.

This repository contains the BindOpen.Logging code source.

A full list of all the BindOpen.Kernel repos is available as well.

Install

To get started, install the BindOpen.Logging module you want to use.

Note: We recommend that later on, you install only the package you need.

From Visual Studio

Module Instruction
BindOpen.Logging PM> Install-Package BindOpen.Logging

From .NET CLI

Module Instruction
BindOpen.Logging > dotnet add package BindOpen.Logging

Get started

Dynamic logs

    ...

    var log = BdoLogging.NewLog().WithTitle("A test log");

    TestMethodA(-1, log);

    if (log.HasErrors()) { Debug.Console(String.Format("Errors found ({0})", log.ToString())); }

    ...

private void TestMethodA(int num, IBdoLog log = null)
{
    if (num>0) { log?.AddWarning("Number should be negative"); return; }

    ...

    var subLog = log.InsertChild(BdoLogging.NewLog().WithTitle("Sub test log"));

    TestMethodA1("B" + num, subLog);
}

private void TestMethodA1(string st, IBdoLog log = null)
{
    if (st?.StartsWith("A") != true) { log?.InsertError("String must start with 'A'").WithResultCode("500"); return; }

    ...
}

Basic loggers

var logger = BdoLogging.NewLogger<BdoTraceLogger>();

var log = logger.NewRootLog();
log.AddCheckpoint("Checkpoint A");
            
logger.Log(log);

External loggers

// Example with Serilog

Log.Logger = new LoggerConfiguration()
    .Enrich.FromLogContext()
    .WriteTo.Console()
    .WriteTo.File(_filePath_serilog, rollingInterval: RollingInterval.Day)
    .CreateLogger();

var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(Log.Logger);

var logger = BdoLogging.NewLogger(loggerFactory);

var log = BdoLogging.NewLog();
log.AddCheckpoint("Checkpoint A");
            
logger.Log(log);

License

This project is licensed under the terms of the MIT license. See LICENSE.

Packages

This BindOpen.Logging module contains the following Nuget packages:

Package Provision
BindOpen.Logging.Abstractions Interfaces and enumerations
BindOpen.Logging Core package
BindOpen.Logging.IO Serialization / Deserialization
BindOpen.Logging.IO.Dtos Data transfer classes

The atomicity of these packages allows you install only what you need respecting your solution's architecture.

All of our NuGet packages are available from our NuGet.org profile page.

Other repos and Projects

BindOpen.Kernel provides the core packages of BindOpen.

BindOpen.Hosting enables you to integrate a BindOpen agent within the .NET service builder.

BindOpen.Labs is a collection of projects based on BindOpen.

A full list of all the repos is available as well.

Documentation and Further Learning

The BindOpen Docs are the ideal place to start if you are new to BindOpen. They are categorized in 3 broader topics:

  • Articles to learn how to use BindOpen;
  • Notes to follow our releases;
  • Api to have an overview of BindOpen APIs.

The BindOpen Blog is where we announce new features, write engineering blog posts, demonstrate proof-of-concepts and features under development.

Feedback

If you're having trouble with BindOpen, file a bug on the BindOpen Issue Tracker.

Donation

You are welcome to support this project. All donations are optional but are greatly appreciated.

Please donate

About

BindOpen.Logging offers a simple and multidimensional logging system, perfect to monitor nested task executions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published