mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:44:37 +03:00
switch to slog.Logger for logging, for easier reuse of packages by external software
we don't want external software to include internal details like mlog. slog.Logger is/will be the standard. we still have mlog for its helper functions, and its handler that logs in concise logfmt used by mox. packages that are not meant for reuse still pass around mlog.Log for convenience. we use golang.org/x/exp/slog because we also support the previous Go toolchain version. with the next Go release, we'll switch to the builtin slog.
This commit is contained in:
@ -3,6 +3,7 @@ package store
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/mjl-/mox/mlog"
|
||||
"github.com/mjl-/mox/mox-"
|
||||
)
|
||||
|
||||
@ -12,7 +13,7 @@ import (
|
||||
// responsible for closing and possibly removing the file. The caller should ensure
|
||||
// the contents of the file are synced to disk before attempting to deliver the
|
||||
// message.
|
||||
func CreateMessageTemp(pattern string) (*os.File, error) {
|
||||
func CreateMessageTemp(log mlog.Log, pattern string) (*os.File, error) {
|
||||
dir := mox.DataDirPath("tmp")
|
||||
os.MkdirAll(dir, 0770)
|
||||
f, err := os.CreateTemp(dir, pattern)
|
||||
@ -22,7 +23,7 @@ func CreateMessageTemp(pattern string) (*os.File, error) {
|
||||
err = f.Chmod(0660)
|
||||
if err != nil {
|
||||
xerr := f.Close()
|
||||
xlog.Check(xerr, "closing temp message file after chmod error")
|
||||
log.Check(xerr, "closing temp message file after chmod error")
|
||||
return nil, err
|
||||
}
|
||||
return f, err
|
||||
|
Reference in New Issue
Block a user