Easy-Log 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Easy-Log --version 2.0.0                
NuGet\Install-Package Easy-Log -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Easy-Log" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Easy-Log --version 2.0.0                
#r "nuget: Easy-Log, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Easy-Log as a Cake Addin
#addin nuget:?package=Easy-Log&version=2.0.0

// Install Easy-Log as a Cake Tool
#tool nuget:?package=Easy-Log&version=2.0.0                

<h1 align="center"> EasyLog </h1> <p align="center"> A simple and user-friendly logging system for .NET projects. </p>

<img src="https://i.imgur.com/NKhyA4h.png" align="middle">

Installation

Install Easy-Log in your project using NuGet Package Manager Console:

dotnet add package Easy-Log

Getting Started

You can use the global instance Log or create your own instance with custom options.

var options = new LoggerOptions
{
    ConsoleLogging = true,         // Log to console
    ShowDateAndTime = true,        // Show Date and time with the log prefix
    FileLogging = true,            // Allow log to file
    FileOutputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App.log") // File output path
};
Logger log = new Logger(options);

If you are using the global instance, set options like this:

Log.SetOptions(options);

Log Types

Easy-Log supports flexible log types. You can create your own by implementing the ILogType interface. Here's an example:

public class Verbose : ILogType
{
    public string Prefix => "VERBOSE"; // Set log prefix
    public Color PrefixColor => Color.Gray; // Set prefix color
    public Color ArgColor => Color.Gray; // Set args color
}

Logging

To log messages, use the Write or WriteLine functions. For logging exceptions, use LogException.

/* structure */
instance.WriteLine<ILogType>(string, args)
instance.Write<ILogType>(string, args)
    
Log.WriteLine<Debug>("Hello World ARG 0: {} ARG 2: {}", 419, 500);
Log.WriteLine<Info>("Hello World ARG 0: {}", 613);
Log.WriteLine<Warning>("Hello World ARG 0: {}", 74);
Log.WriteLine<Error>("Hello World ARG 0: {}", 42);

try
{
    List<int> list = new List<int>();
    var item = list[10];
}
catch (Exception e)
{
    Log.LogException(e);
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.2 171 3/16/2024
2.0.1 134 2/27/2024
2.0.0 259 12/6/2023
1.0.5 461 4/21/2022
1.0.4 408 4/19/2022
1.0.3 468 2/5/2022
1.0.2 420 1/23/2022
1.0.1 440 1/22/2022
1.0.0 445 1/22/2022

Whole project rewrite see sample project for example how to use