monobank-firefly3-bot/app/logger.go

23 lines
342 B
Go
Raw Normal View History

2024-04-12 13:00:28 +03:00
package app
2024-03-26 19:06:31 +02:00
import (
"fmt"
"os"
)
func LogString(str string) {
if len(os.Getenv("LOG_FILE")) == 0 {
return
}
f, err := os.OpenFile(os.Getenv("LOG_FILE"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println(err)
}
defer f.Close()
if _, err := f.WriteString(str + "\n"); err != nil {
fmt.Println(err)
}
}