LoggerBot 1.2.1

dotnet add package LoggerBot --version 1.2.1                
NuGet\Install-Package LoggerBot -Version 1.2.1                
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="LoggerBot" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LoggerBot --version 1.2.1                
#r "nuget: LoggerBot, 1.2.1"                
#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 LoggerBot as a Cake Addin
#addin nuget:?package=LoggerBot&version=1.2.1

// Install LoggerBot as a Cake Tool
#tool nuget:?package=LoggerBot&version=1.2.1                

LoggerBot NuGet Package

Overview

The LoggerBot NuGet package provides a logging service that integrates with Telegram bots. It allows developers to easily log messages of various types (error, info, warning, success, and generic messages) to a designated Telegram chat using a Telegram bot.

Installation

You can install the LoggerBot NuGet package via the NuGet Package Manager or the .NET CLI:


dotnet add package LoggerBot

Usage

  1. Configure LoggerBot First, configure LoggerBot in your application's startup code to register the logger service in the dependency injection container:

using LoggerBot;

builder.Services.AddLoggerBot();
  1. Inject and Use LoggerService Inject the ILoggerService interface into your classes where logging is required and use its methods to log messages:

using LoggerBot.Services;

public class MyClass
{
    private readonly ILoggerService _logger;

    public MyClass(ILoggerService logger)
    {
        _logger = logger;
    }

    public async Task SomeMethod()
    {
        // Log an error message
        await _logger.ErrorAsync("An error occurred.");

        // Log an info message
        await _logger.InfoAsync("Some information message.");

        // Log a success message
        await _logger.SuccessAsync("Operation completed successfully.");

        // Log a warning message
        await _logger.WarningAsync("Warning: Resource limit exceeded.");

        // Log a generic message
        await _logger.MessageAsync("A generic message.");
    }
}

Configuration

The LoggerBot requires configuration settings to connect to your Telegram bot. Ensure the following configuration keys are present in your appsettings.json or environment variables:

LoggerBot:Token: The token of your Telegram bot.

LoggerBot:ChatId: The ID of the Telegram chat where logs will be sent.

Example:


"LoggerBot": {
  "Token": "bot-token",
  "ChatId": "-100chatId"
}

Supported Log Types

  • Error: Used for logging error messages.

  • Info: Used for logging informational messages.

  • Success: Used for logging success messages.

  • Warning: Used for logging warning messages.

  • Message: Used for logging generic messages.

Feel free to expand upon this documentation with more details specific to your package's usage or additional features!

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 (1)

Showing the top 1 NuGet packages that depend on LoggerBot:

Package Downloads
GlobalErrorHandler

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 40 11/29/2024
1.2.0 40 11/29/2024
1.1.1 97 11/7/2024
1.1.0 73 11/7/2024
1.0.0 230 5/6/2024