func OpenFile(name string, mode os.FileMode) (*os.File, error) {
	logDir := filepath.Dir(name)
	err := os.MkdirAll(logDir, 0750)
	if err != nil {
		return nil, fmt.Errorf("failed to create log file directory %s: %w", logDir, err)
	}
	return os.OpenFile(name, os.O_WRONLY|os.O_APPEND|os.O_CREATE, mode)
}
OpenFile opens a new or appends to an existing log file.
The parent directory is created if it does not exist.
package log
import (
	"fmt"
	"io"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"time"
	"github.com/rs/zerolog"
)
const (
	TraceLevel = zerolog.TraceLevel
	DebugLevel = zerolog.DebugLevel
	InfoLevel  = zerolog.InfoLevel
	WarnLevel  = zerolog.WarnLevel
	ErrorLevel = zerolog.ErrorLevel
	FatalLevel = zerolog.FatalLevel
	PanicLevel = zerolog.PanicLevel
)
func init() {
	zerolog.LevelFieldName = "l"
	zerolog.MessageFieldName = "m"
	zerolog.TimestampFieldName = "t"
	zerolog.TimestampFunc = func() time.Time {
		return time.Now().UTC()
	}
	zerolog.CallerFieldName = "c"
	zerolog.CallerMarshalFunc = func(file string, line int) string {
		return filepath.Base(file) + ":" + strconv.Itoa(line)
	}
}