Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nodirbek-abdulaxadov/loggerbot
https://github.com/nodirbek-abdulaxadov/loggerbot
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nodirbek-abdulaxadov/loggerbot
- Owner: Nodirbek-Abdulaxadov
- Created: 2024-05-06T04:46:29.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-11-29T04:12:28.000Z (about 1 month ago)
- Last Synced: 2024-11-29T05:20:45.079Z (about 1 month ago)
- Language: C#
- Size: 170 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# 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:```bash
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:```csharp
using LoggerBot;
builder.Services.AddLoggerBot();
```2. Inject and Use LoggerService
Inject the ILoggerService interface into your classes where logging is required and use its methods to log messages:```csharp
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:
```json"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!