Skip to content

Commit

Permalink
Log to CHIA_ROOT/log
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender committed Dec 18, 2023
1 parent 9d284e2 commit e536281
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/utils/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ package utils

import (
"os"
"path/filepath"

"github.com/chia-network/go-chia-libs/pkg/config"
log "github.com/sirupsen/logrus"
)

// LogToFile logs a message to a given file
func LogToFile(filename, message string) error {
file, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
rootPath, err := config.GetChiaRootPath()
if err != nil {
return err
}
path := filepath.Join(rootPath, "log", filename)
file, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
Expand Down

0 comments on commit e536281

Please sign in to comment.