Commit a62c16cbdacc61744825a9b190f762f371aba6c0

Authored by Marko Tikvić
1 parent 093191eb22
Exists in master

more detailed printing

Showing 1 changed file with 10 additions and 12 deletions   Show diff stats
... ... @@ -60,11 +60,6 @@ func New(name string, maxFileSize int64) (logger *Logger, err error) {
60 60 return logger, nil
61 61 }
62 62  
63   -func (l *Logger) Print(format string, v ...interface{}) {
64   - msg := fmt.Sprintf(format, v...)
65   - fmt.Printf(time.Now().Format(time.RFC3339) + ": " + msg + "\n")
66   -}
67   -
68 63 func (l *Logger) Log(format string, v ...interface{}) {
69 64 if l.outputFile == nil {
70 65 return
... ... @@ -121,6 +116,13 @@ func (l *Logger) CombineHTTPLogs(in string, out string) {
121 116 l.outputFile.WriteString(msg)
122 117 }
123 118  
  119 +func (l *Logger) Print(format string, v ...interface{}) {
  120 + _, file, line, _ := runtime.Caller(1)
  121 +
  122 + msg := fmt.Sprintf(format, v...)
  123 + fmt.Printf("%s: %s %d: %s\n", time.Now().Format(time.RFC3339), file, line, msg)
  124 +}
  125 +
124 126 func (l *Logger) Trace(format string, v ...interface{}) {
125 127 if l.outputFile == nil {
126 128 return
... ... @@ -128,15 +130,11 @@ func (l *Logger) Trace(format string, v ...interface{}) {
128 130  
129 131 l.mu.Lock()
130 132 defer l.mu.Unlock()
131   - _, file, line, ok := runtime.Caller(1)
132 133  
133   - s := ""
  134 + _, file, line, _ := runtime.Caller(1)
134 135 msg := fmt.Sprintf(format, v...)
135   - if ok {
136   - s = fmt.Sprintf("%s: %s %d: %s\n", time.Now().Format(time.RFC3339), file, line, msg)
137   - } else {
138   - s = fmt.Sprintf(time.Now().Format(time.RFC3339) + ": [can't retreive stack details]:" + msg + "\n")
139   - }
  136 + s := fmt.Sprintf("%s: %s %d: %s\n", time.Now().Format(time.RFC3339), file, line, msg)
  137 +
140 138 if l.shouldSplit(len(s)) {
141 139 l.split()
142 140 }
... ...