From 539e175631a2efa39db09ffa1ad0cafe13a51167 Mon Sep 17 00:00:00 2001 From: ren yuze Date: Wed, 23 Dec 2020 20:54:03 +0800 Subject: [PATCH] bug fix:Cannot Close Log File --- archive.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archive.go b/archive.go index 5fc36c0..33464a1 100644 --- a/archive.go +++ b/archive.go @@ -33,7 +33,7 @@ type logfileinfo struct { func SetLogFile(path string, logger *StarLogger, appendMode bool) error { var fileMode int if appendMode { - fileMode = os.O_APPEND | os.O_CREATE + fileMode = os.O_APPEND | os.O_CREATE | os.O_WRONLY } else { fileMode = os.O_CREATE | os.O_WRONLY } @@ -83,7 +83,7 @@ func SetLogFile(path string, logger *StarLogger, appendMode bool) error { func CloseWithSwitching(logger *StarLogger) error { if archMap.MustGet(logger.logcore.id) != nil { logger.SetSwitching(true) - err := archMap.MustGet(logger.logcore.id).(*os.File).Close() + err := archMap.MustGet(logger.logcore.id).(logfileinfo).pointer.Close() if err != nil { logger.logcore.output = nil return err