-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogcalls.go
91 lines (70 loc) · 3.79 KB
/
logcalls.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2013 Ardan Studios. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE handle.
// Package tracelog : logcalls.go provides formatting functions.
package tracelog
import (
"fmt"
)
//** STARTED AND COMPLETED
// Started uses the Serialize destination and adds a Started tag to the log line
func Started(title string, functionName string) {
logger.Trace.Output(2, fmt.Sprintf("%s : %s : Started\n", title, functionName))
}
// Startedf uses the Serialize destination and writes a Started tag to the log line
func Startedf(title string, functionName string, format string, a ...interface{}) {
logger.Trace.Output(2, fmt.Sprintf("%s : %s : Started : %s\n", title, functionName, fmt.Sprintf(format, a...)))
}
// Completed uses the Serialize destination and writes a Completed tag to the log line
func Completed(title string, functionName string) {
logger.Trace.Output(2, fmt.Sprintf("%s : %s : Completed\n", title, functionName))
}
// Completedf uses the Serialize destination and writes a Completed tag to the log line
func Completedf(title string, functionName string, format string, a ...interface{}) {
logger.Trace.Output(2, fmt.Sprintf("%s : %s : Completed : %s\n", title, functionName, fmt.Sprintf(format, a...)))
}
// CompletedError uses the Error destination and writes a Completed tag to the log line
func CompletedError(err error, title string, functionName string) {
logger.Error.Output(2, fmt.Sprintf("%s : %s : Completed : ERROR : %s\n", title, functionName, err))
}
// CompletedErrorf uses the Error destination and writes a Completed tag to the log line
func CompletedErrorf(err error, title string, functionName string, format string, a ...interface{}) {
logger.Error.Output(2, fmt.Sprintf("%s : %s : Completed : ERROR : %s : %s\n", title, functionName, fmt.Sprintf(format, a...), err))
}
//** TRACE
// Trace writes to the Trace destination
func Trace(title string, functionName string, format string, a ...interface{}) {
logger.Trace.Output(2, fmt.Sprintf("%s : %s : Info : %s\n", title, functionName, fmt.Sprintf(format, a...)))
}
//** INFO
// Info writes to the Info destination
func Info(title string, functionName string, format string, a ...interface{}) {
logger.Info.Output(2, fmt.Sprintf("%s : %s : Info : %s\n", title, functionName, fmt.Sprintf(format, a...)))
}
//** WARNING
// Warning writes to the Warning destination
func Warning(title string, functionName string, format string, a ...interface{}) {
logger.Warning.Output(2, fmt.Sprintf("%s : %s : Info : %s\n", title, functionName, fmt.Sprintf(format, a...)))
}
//** ERROR
// Error writes to the Error destination and accepts an err
func Error(err error, title string, functionName string) {
logger.Error.Output(2, fmt.Sprintf("%s : %s : ERROR : %s\n", title, functionName, err))
}
// Errorf writes to the Error destination and accepts an err
func Errorf(err error, title string, functionName string, format string, a ...interface{}) {
logger.Error.Output(2, fmt.Sprintf("%s : %s : ERROR : %s : %s\n", title, functionName, fmt.Sprintf(format, a...), err))
}
//** ALERT
// Alert write to the Error destination and sends email alert
func Alert(subject string, title string, functionName string, format string, a ...interface{}) {
message := fmt.Sprintf("%s : %s : ALERT : %s\n", title, functionName, fmt.Sprintf(format, a...))
logger.Error.Output(2, message)
SendEmailException(subject, message)
}
// CompletedAlert write to the Error destination, writes a Completed tag to the log line and sends email alert
func CompletedAlert(subject string, title string, functionName string, format string, a ...interface{}) {
message := fmt.Sprintf("%s : %s : Completed : ALERT : %s\n", title, functionName, fmt.Sprintf(format, a...))
logger.Error.Output(2, message)
SendEmailException(subject, message)
}