Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
docs(onelog): update usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoksr committed Jul 22, 2023
1 parent 6b4e2ce commit 0fcea52
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,37 @@
// with logging setup and promotes consistency in logging across different parts of a project or across different projects.
//
// Here is a brief example using the zapadapter and slogadapter:

// import (
// "go.uber.org/zap"
// "github.com/nikoksr/onelog"
// "github.com/nikoksr/onelog/zapadapter"
// "github.com/nikoksr/onelog/slogadapter"
// )
//
// type superTracker struct {
// superEventLogger onelog.Logger
// }
//
// func main() {
// // Let's use zap's development logger as our superhero event logger
// logger, _ := zap.NewDevelopment()
//
// tracker := &superTracker{
// superEventLogger: zapadapter.NewAdapter(logger),
// }
//
// // Now let's log a superhero event
// tracker.superEventLogger.Info().Msg("Superman spotted in New York!")
//
// // Or perhaps we'd rather use slog for logging our superhero sightings
// logger := slog.Default()
// tracker.superEventLogger = slogadapter.NewAdapter(logger)
//
// // And now we can log another sighting
// tracker.superEventLogger.Info().Msg("Wonder Woman seen flying over Paris!")
// }
//
// package main
//
// import (
// "go.uber.org/zap"
// "golang.org/x/exp/slog"
//
// "github.com/nikoksr/onelog"
// slogadapter "github.com/nikoksr/onelog/adapter/slog"
// zapadapter "github.com/nikoksr/onelog/adapter/zap"
// )
//
// type superheroTracker struct {
// logger onelog.Logger
// }
//
// func main() {
// // Let's use zap's development logger as our superhero event logger
// logger, _ := zap.NewDevelopment()
//
// heroes := &superheroTracker{
// logger: zapadapter.NewAdapter(logger),
// }
//
// // Now let's log a superhero event
// heroes.logger.Info().Msg("Superman spotted in New York!")
//
// // Or perhaps we'd rather use slog for logging our superhero sightings
// heroes.logger = slogadapter.NewAdapter(slog.Default())
//
// // And now we can log another sighting
// heroes.logger.Info().Msg("Wonder Woman seen flying over Paris!")
// }
package onelog

0 comments on commit 0fcea52

Please sign in to comment.