cleaned up structure

This commit is contained in:
2026-01-01 14:54:14 +11:00
parent e9a4696c99
commit 72e1513fae
3 changed files with 50 additions and 36 deletions

23
hlog/logfile.go Normal file
View File

@@ -0,0 +1,23 @@
package hlog
import (
"os"
"path/filepath"
"github.com/pkg/errors"
)
// Returns a pointer to a new log file with the specified path.
// Remember to call file.Close() when finished writing to the log file
func NewLogFile(path string) (*os.File, error) {
logPath := filepath.Join(path, "server.log")
file, err := os.OpenFile(
logPath,
os.O_APPEND|os.O_CREATE|os.O_WRONLY,
0663,
)
if err != nil {
return nil, errors.Wrap(err, "os.OpenFile")
}
return file, nil
}