github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/loki/test/main.go (about)

     1  package main
     2  
     3  import (
     4  	"log"
     5  	"time"
     6  
     7  	"github.com/binkynet/BinkyNet/loki"
     8  	"github.com/rs/zerolog"
     9  )
    10  
    11  func main() {
    12  	lw, err := loki.NewLokiLogger("http://localhost:3100", "testapp", 0)
    13  	if err != nil {
    14  		log.Fatalf("NewLokiLogger failed: %s\n", err)
    15  	}
    16  	log := zerolog.New(lw).With().Timestamp().Logger()
    17  
    18  	log.Debug().Msg("Hello logger")
    19  	for i := 0; i < 50; i++ {
    20  		go func(i int) {
    21  			log.Info().
    22  				Int("i", i).
    23  				Str("foo", "bar").
    24  				Bool("ok", true).
    25  				Msgf("Message %d", i)
    26  		}(i)
    27  	}
    28  	time.Sleep(time.Second * 5)
    29  }