github.com/scottcagno/storage@v1.8.0/pkg/_junk/_logger/logger_test.go (about)

     1  package logger
     2  
     3  import (
     4  	"log"
     5  	"os"
     6  	"testing"
     7  )
     8  
     9  var multiLine = `this is going to be a multi line log. It will show
    10  you what will happen when the logger
    11  encounters a multi level log message.
    12  Here you go!`
    13  
    14  func TestStdLog(t *testing.T) {
    15  	l := log.New(os.Stderr, "", log.LstdFlags)
    16  	l.Printf("this is my log: %s\n", "logging something")
    17  
    18  	l.Printf("this is my log: %s\n", "logging something")
    19  }
    20  
    21  func TestPrintColors(t *testing.T) {
    22  
    23  	l := NewLogger()
    24  
    25  	l.Info(multiLine)
    26  
    27  	l.Trace("this is a *trace* log\n\tthis is still the same trace log...")
    28  
    29  	l.Debug("this is a *debug* log")
    30  
    31  	l.Info("this is a *info* log")
    32  
    33  	l.Info("turning on the func printer")
    34  
    35  	l.SetPrintFunc(true)
    36  
    37  	l.Print("this is a *default* log")
    38  
    39  	l.Warn("this is a *warn* log")
    40  
    41  	l.Info("turning on the file printer")
    42  
    43  	l.SetPrintFile(true)
    44  
    45  	l.Warn("there we go! is it working?")
    46  
    47  	l.Error("this is a *error* log")
    48  
    49  	l.Info("turning off the func printer")
    50  
    51  	l.SetPrintFunc(false)
    52  
    53  	l.Info("and we're done.")
    54  
    55  	l.Info("so is this working too?")
    56  
    57  	l.Error("hmmm i really hope so")
    58  
    59  	l.Warn("otherwise, i am not sure what I will do!")
    60  
    61  	recover()
    62  
    63  }