blob: 0ef51e908d04a2620aab59bed9d0482b03b675c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package logger
import (
"io"
"log"
"os"
)
var (
Debug *log.Logger
Info *log.Logger
Error *log.Logger
)
func Init(
debugHandle io.Writer,
infoHandle io.Writer,
errorHandle io.Writer) {
Debug = log.New(debugHandle,
"DEBUG: ",
log.Ldate|log.Ltime|log.Lshortfile)
Info = log.New(infoHandle,
"INFO: ",
log.Ldate|log.Ltime|log.Lshortfile)
Error = log.New(errorHandle,
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
}
func CreateLogFile(path string) *os.File {
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Println(err)
}
return f
}
|