Autocreate errors log file
This commit is contained in:
parent
8278ce50c3
commit
3c0add8c6b
15
errFS.go
15
errFS.go
|
@ -9,6 +9,21 @@ import (
|
|||
var errFS *os.File = nil
|
||||
var errFSLock sync.Mutex
|
||||
|
||||
func init() {
|
||||
bn, e := os.Executable()
|
||||
if e != nil {
|
||||
panic("Can not get executable name")
|
||||
}
|
||||
ef, e := os.OpenFile(bn+".error", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0665)
|
||||
if e != nil {
|
||||
panic("Can not open or create error log file")
|
||||
}
|
||||
err := InitFS(ef)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func InitFS(f *os.File) *Err {
|
||||
errFS = f
|
||||
errFSLock = sync.Mutex{}
|
||||
|
|
Loading…
Reference in New Issue