github.com/devops-filetransfer/sshego@v7.0.4+incompatible/verbose.go (about)

     1  package sshego
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  // Verbose can be set to true for debug output. For production builds it
     9  // should be set to false, the default.
    10  const Verbose bool = false
    11  
    12  // Ts gets the current timestamp for logging purposes.
    13  func ts() string {
    14  	return time.Now().Format("2006-01-02 15:04:05.999 -0700 MST")
    15  }
    16  
    17  // time-stamped fmt.Printf
    18  func tSPrintf(format string, a ...interface{}) {
    19  	fmt.Printf("\n%s ", ts())
    20  	fmt.Printf(format+"\n", a...)
    21  }
    22  
    23  // VPrintf is like fmt.Printf, but only prints if Verbose is true. Uses TSPrint
    24  // to mark each print with a timestamp.
    25  func p(format string, a ...interface{}) {
    26  	if Verbose {
    27  		tSPrintf(format, a...)
    28  	}
    29  }
    30  
    31  func pp(format string, a ...interface{}) {
    32  	tSPrintf(format, a...)
    33  }