github.com/network-quality/goresponsiveness@v0.0.0-20240129151524-343954285090/debug/debug.go (about) 1 /* 2 * This file is part of Go Responsiveness. 3 * 4 * Go Responsiveness is free software: you can redistribute it and/or modify it under 5 * the terms of the GNU General Public License as published by the Free Software Foundation, 6 * either version 2 of the License, or (at your option) any later version. 7 * Go Responsiveness is distributed in the hope that it will be useful, but WITHOUT ANY 8 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 9 * PARTICULAR PURPOSE. See the GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License along 12 * with Go Responsiveness. If not, see <https://www.gnu.org/licenses/>. 13 */ 14 15 package debug 16 17 type DebugLevel int8 18 19 const ( 20 NoDebug DebugLevel = iota 21 Debug 22 Warn 23 Error 24 ) 25 26 type DebugWithPrefix struct { 27 Level DebugLevel 28 Prefix string 29 } 30 31 func NewDebugWithPrefix(level DebugLevel, prefix string) *DebugWithPrefix { 32 return &DebugWithPrefix{Level: level, Prefix: prefix} 33 } 34 35 func (d *DebugWithPrefix) String() string { 36 return d.Prefix 37 } 38 39 func IsDebug(level DebugLevel) bool { 40 return level <= Debug 41 } 42 43 func IsWarn(level DebugLevel) bool { 44 return level <= Warn 45 } 46 47 func IsError(level DebugLevel) bool { 48 return level <= Error 49 }