forked from lalluviamola/web-blog
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.go
More file actions
47 lines (39 loc) · 666 Bytes
/
log.go
File metadata and controls
47 lines (39 loc) · 666 Bytes
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
40
41
42
43
44
45
46
47
package main
import (
"context"
"fmt"
)
var (
logVerbose = false
)
func logf(ctx context.Context, s string, args ...interface{}) {
if len(args) > 0 {
s = fmt.Sprintf(s, args...)
}
fmt.Print(s)
}
func logerrf(ctx context.Context, format string, args ...interface{}) {
s := format
if len(args) > 0 {
s = fmt.Sprintf(format, args...)
}
fmt.Printf("Error: %s", s)
}
func logvf(s string, args ...interface{}) {
if !logVerbose {
return
}
if len(args) > 0 {
s = fmt.Sprintf(s, args...)
}
fmt.Print(s)
}
var (
doTempLog = false
)
func logTemp(format string, args ...interface{}) {
if !doTempLog {
return
}
logf(ctx(), format, args...)
}