|
1 /* |
|
2 * Copyright (C) 2014-2018 Mikael Berthe <mikael@lilotux.net> |
|
3 * |
|
4 * This program is free software; you can redistribute it and/or modify |
|
5 * it under the terms of the GNU General Public License as published by |
|
6 * the Free Software Foundation; either version 2 of the License, or (at |
|
7 * your option) any later version. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, but |
|
10 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 * General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
17 * USA |
|
18 */ |
|
19 |
|
20 package main |
|
21 |
|
22 import ( |
|
23 "fmt" |
|
24 "log" |
|
25 "os" |
|
26 ) |
|
27 |
|
28 type myLogT struct { |
|
29 verbosity int |
|
30 } |
|
31 |
|
32 func (l *myLogT) Printf(level int, format string, args ...interface{}) { |
|
33 if level > l.verbosity { |
|
34 return |
|
35 } |
|
36 if level >= 0 { |
|
37 log.Printf(format, args...) |
|
38 return |
|
39 } |
|
40 // Error message without timestamp |
|
41 fmt.Fprintf(os.Stderr, format, args...) |
|
42 } |
|
43 |
|
44 func (l *myLogT) Println(level int, args ...interface{}) { |
|
45 if level > l.verbosity { |
|
46 return |
|
47 } |
|
48 if level >= 0 { |
|
49 log.Println(args...) |
|
50 return |
|
51 } |
|
52 // Error message without timestamp |
|
53 fmt.Fprintln(os.Stderr, args...) |
|
54 } |
|
55 |
|
56 func (l *myLogT) Fatal(args ...interface{}) { |
|
57 log.Fatal(args...) |
|
58 } |
|
59 |
|
60 func (l *myLogT) SetBenchFlags() { |
|
61 log.SetFlags(log.LstdFlags | log.Lmicroseconds) |
|
62 } |