mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-22 20:56:02 +03:00
28 lines
333 B
Go
28 lines
333 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
type Logger struct {
|
|
out *os.File
|
|
}
|
|
|
|
func (l Logger) Log(s string) {
|
|
out := l.out
|
|
if out == nil {
|
|
out = os.Stderr
|
|
}
|
|
fmt.Fprintf(out, "%s [%d]: %s\n", os.Args[0],
|
|
os.Getpid(), s)
|
|
}
|
|
func (l *Logger) SetOutput(out *os.File) {
|
|
l.out = out
|
|
}
|
|
|
|
func main() {
|
|
l := Logger{}
|
|
l.Log("test")
|
|
}
|