BMLogger 1.1.0
See the version list below for details.
dotnet add package BMLogger --version 1.1.0
NuGet\Install-Package BMLogger -Version 1.1.0
<PackageReference Include="BMLogger" Version="1.1.0" />
paket add BMLogger --version 1.1.0
#r "nuget: BMLogger, 1.1.0"
// Install BMLogger as a Cake Addin #addin nuget:?package=BMLogger&version=1.1.0 // Install BMLogger as a Cake Tool #tool nuget:?package=BMLogger&version=1.1.0
<p align="center"> <img src="https://raw.githubusercontent.com/AnemonOFF/BMLogger/main/logo.png" alt="BMLogger"> <h1 align="center">BMLogger</h1> </p> <p align="center"> <a href="https://www.nuget.org/packages/BMLogger/"><img alt="Nuget" src="https://img.shields.io/nuget/v/BMLogger"></a> <a href="https://github.com/AnemonOFF/BMLogger/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/AnemonOFF/BMLogger"></a> </p> </br>
A simple C# file and console logger with log level separate.
How to use
- Firstly create log provider
var provider = new BMLoggerProvider();
| Agrument | type | required | default | description | |-----------------|----------|----------|----------|--------------------------------------------------| | dir | string | - | bmlogger | path to directory of logs | | expiration | TimeSpan | - | 30 days | time from last log in file. If greater - delete | | maxFileSizeInMb | int | - | 20 Mb | max file size on provider init. If greater - cut | | logInConsole | bool | - | true | flag to log in console | 2. Create logger by provider. DO NOT create it by yourself (using new BMLogger().
var logger = provider.CreateLogger("name");
| Agrument | type | required | default | description | |-----------------|--------|----------|---------|----------------------------------------------------------------| | name | string | + | | name of logger and its file | | logDateTime | bool | - | true | flag to log date and time of message | | logCallerPath | bool | - | true | flag to log path to file from where log function was called | | logCallerMember | bool | - | true | flag to log method and line from where log function was called | 3. Log your message
// Use default method with any LogLevel
logger.Log("any log level message", LogLevel.INFO);
await logger.LogAsync("async any log level message", LogLevel.INFO);
// Or you can use short cuts for LogLevels
logger.Info("info message");
await logger.InfoAsync("async info message");
logger.Warn("warn message");
await logger.WarnAsync("async warn message");
logger.Error("error message");
await logger.ErrorAsync("async error message");
logger.Fatal("fatal message");
await logger.FatalAsync("async fatal message");
logger.Success("success message");
await logger.SuccessAsync("async success message");
Log levels
- INFO - default log level
- SUCCESS - success message with green color in console
- WARN - warning message with orange color in console
- ERROR - error message with red color in console
- FATAL - fatal error message with red background color in console
Asynchronous
All log methods have async analogues. File operations are thread-safe by lock constructions.
BUT! When you use async methods be careful with third party console output, because colored message can not be in time to reset console color scheme to default.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.