Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codenoid/telelog
Embed to your app or tail a file, send the log to your telegram account &/ group
https://github.com/codenoid/telelog
golang logger telegram
Last synced: 19 days ago
JSON representation
Embed to your app or tail a file, send the log to your telegram account &/ group
- Host: GitHub
- URL: https://github.com/codenoid/telelog
- Owner: codenoid
- License: mit
- Created: 2020-10-14T17:10:11.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-08T13:24:47.000Z (about 3 years ago)
- Last Synced: 2024-10-02T06:20:40.157Z (about 1 month ago)
- Topics: golang, logger, telegram
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telelog
[![Go Reference](https://pkg.go.dev/badge/github.com/codenoid/telelog.svg)](https://pkg.go.dev/github.com/codenoid/telelog)
Embed to app or tail a file, the log will send to your telegram (chat_id)
![Telegram Notification](telelog.jpg?raw=true)
## Installation
Embed to your app using Go Modules
```bash
go get github.com/codenoid/telelog
```CLI version
```bash
go get github.com/codenoid/telelog/cmd/telelog
```## Usage
Example of recipient file content (text file) :
```txt
999838460
961268461
827957192
```CMD Example :
you must set env var for cli version !
```bash
$ codenoid> telelog
Telelog, make sure you already set these env :
TELELOG_BOT_TOKEN
TELELOG_APP_NAME
TELELOG_DEBUG_MODE (optional)
TELELOG_RECIPIENT_LIST$ codenoid> telelog -file ./path/to/error.log -level error
```Code Example :
```go
package mainimport (
"time""github.com/codenoid/telelog"
)func main() {
logger := telelog.LoggerNew()// default TELELOG_BOT_TOKEN, unless you call SetToken
logger.SetToken("1125121251:AAF2sfBCbKjag8LhUIAzf1mzk36BxcJ0Mvg")// default TELELOG_APP_NAME, unless you call SetAppName
logger.SetAppName("Uploader Service")// default TELELOG_DEBUG_MODE, unless you call SetDebug
// if true, any logger.Debug* log will be send
logger.SetDebug(false)// default TELELOG_RECIPIENT_LIST (single path to file), unless you call SetRecipient
logger.SetRecipient("/path/to/text/file.txt", "/second/file/that/contain/chat_id.txt")// or reader
f, _ := os.Open("file.txt")
logger.SetRecipientFromReader(f)// or []byte
logger.SetRecipientFromByte([]byte{"777000\n"})logger.Warn("Warning! your app will be error")
logger.Error("yo, this is error, in 2sec your app will dead")
time.Sleep(2*time.Second)
logger.Fatal("lmaoo")}
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)