| 1 |
// Copyright ©2011-2012 The bíogo Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package util |
| 6 |
|
| 7 |
import ( |
| 8 |
"fmt" |
| 9 |
"os" |
| 10 |
) |
| 11 |
|
| 12 |
type Debug bool |
| 13 |
|
| 14 |
func (d Debug) Println(args ...interface{}) { |
| 15 |
if d { |
| 16 |
caller := GetCaller(1) |
| 17 |
fmt.Fprintf(os.Stderr, "%s %s#%d:", caller.Package, caller.File, caller.Line) |
| 18 |
fmt.Fprintln(os.Stderr, args...) |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
func (d Debug) Printf(format string, args ...interface{}) { |
| 23 |
if d { |
| 24 |
caller := GetCaller(1) |
| 25 |
fmt.Fprintf(os.Stderr, "%s %s#%d:", caller.Package, caller.File, caller.Line) |
| 26 |
fmt.Fprintf(os.Stderr, format, args...) |
| 27 |
} |
| 28 |
} |