Created
January 26, 2023 07:47
-
-
Save arriqaaq/09ff09f453c2457d8851b4672d8a66ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Logger struct { | |
file *os.File | |
} | |
func (l *Logger) Log(message string) { | |
_, _ = l.file.WriteString(message + "\n") | |
} | |
var logger *Logger | |
func GetLogger() *Logger { | |
if logger == nil { | |
file, _ := os.OpenFile("log.txt", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) | |
logger = &Logger{file: file} | |
} | |
return logger | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment