bug fix:Cannot Close Log File

newgen
兔子 4 years ago
parent 044ca3e36a
commit 539e175631

@ -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

Loading…
Cancel
Save