https://github.com/quirel/telegram-logger
Simple logger for sending messages into telegram chats
https://github.com/quirel/telegram-logger
alerting go golang logger logging telegram telegram-bot
Last synced: 6 months ago
JSON representation
Simple logger for sending messages into telegram chats
- Host: GitHub
- URL: https://github.com/quirel/telegram-logger
- Owner: Quirel
- License: mit
- Created: 2021-02-05T10:46:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-07T06:02:26.000Z (over 5 years ago)
- Last Synced: 2024-06-21T09:07:38.652Z (about 2 years ago)
- Topics: alerting, go, golang, logger, logging, telegram, telegram-bot
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram logger
[](https://pkg.go.dev/github.com/quirel/telegram-logger)
Logger to send message in telegram chats.
Package created for some log notification for **pet/small projects**.
It's not suitable for something like access.log on highloaded projects.
## Features
- Send messages to multiple chats
- Set log level: debug | info | warn | error
- Set custom labels for different levels
- Set app_name, which will be displayed in a message
(when use same chat for logs from different apps)
## Example
```go
package main
import tglog "github.com/quirel/telegram-logger"
func main() {
token := "YOUR_TELEGRAM_BOT_TOKEN"
chatIds := []int64{123123, 456456}
// creates logger with level 'debug'
logger, _ := tglog.NewLogger("debug", token, chatIds)
// set name displayed in logs
logger.SetName("MyApp")
logger.Debug("Debug message") // "MyApp, 👾 DEBUG\nDebug message"
logger.Info("Info message") // "MyApp, 🔵 INFO\nInfo message"
logger.Warn("Warning message") // "MyApp, ⚠️ WARN\nWarning message"
logger.Error("Error message") // "MyApp, ❌ ERROR\nError message"
labels := tglog.LevelLabels{
Debug: "dbg", Info: "inf", Warn: "wrn", Error: "err",
}
// Set not default labels for different log levels
logger.SetLabels(&labels)
logger.Debug("Debug message") // "MyApp, dbg\nDebug message"
}
```