Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package z | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// 给一个总开关, 这样在调试的时候就可以使用总开关关闭打印语句了 | ||
var _print_on_ bool = false | ||
|
||
func IsDebugOn() bool { | ||
return _print_on_ | ||
} | ||
|
||
func DebugOn() { | ||
_print_on_ = true | ||
} | ||
|
||
func DebugOff() { | ||
_print_on_ = false | ||
} | ||
|
||
func DebugPrint(a ...interface{}) (n int, err error) { | ||
if _print_on_ { | ||
return fmt.Print(a...) | ||
} | ||
return 0, nil | ||
} | ||
|
||
func DebugPrintf(format string, a ...interface{}) (n int, err error) { | ||
if _print_on_ { | ||
return fmt.Printf(format, a...) | ||
} | ||
return 0, nil | ||
} | ||
|
||
func DebugPrintln(a ...interface{}) (n int, err error) { | ||
if _print_on_ { | ||
return fmt.Println(a...) | ||
} | ||
return 0, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters