mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
fce3edf7db
* feat!: cleanup Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * more cleanup Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: more cleanup Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: more cleanup --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
27 lines
491 B
Go
27 lines
491 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/adrg/xdg"
|
|
"github.com/charmbracelet/log"
|
|
)
|
|
|
|
func getLogFilePath() (string, error) {
|
|
return xdg.CacheFile("glow/glow.log")
|
|
}
|
|
|
|
func setupLog() (func() error, error) {
|
|
// Log to file, if set
|
|
logFile, err := getLogFilePath()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
f, err := os.OpenFile(logFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
log.SetOutput(f)
|
|
log.SetLevel(log.DebugLevel)
|
|
return f.Close, nil
|
|
}
|