github.com/platinasystems/nvram@v1.0.1-0.20190709235807-51a23abd5aec/debug/debug.go (about)

     1  // Copyright © 2019 Platina Systems, Inc. All rights reserved.
     2  // Use of this source code is governed by the GPL-2 license described in the
     3  // LICENSE file.
     4  
     5  // +build debug
     6  
     7  package debug
     8  
     9  import (
    10  	"fmt"
    11  )
    12  
    13  const (
    14  	LevelNone = iota
    15  	LevelMSG1 = iota
    16  	LevelMSG2 = iota
    17  	LevelMSG3 = iota
    18  )
    19  
    20  var dbgLevel = LevelMSG3
    21  
    22  func SetDebugLevel(level int) {
    23  	dbgLevel = level
    24  }
    25  
    26  func Trace(level int, s string, a ...interface{}) {
    27  	if level <= dbgLevel {
    28  		fmt.Printf(s, a...)
    29  	}
    30  }