This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package nopadapter | ||
|
||
import ( | ||
"net" | ||
"time" | ||
|
||
"github.com/nikoksr/onelog" | ||
) | ||
|
||
// Compile-time check that Adapter and Context implements onelog.Logger and onelog.LoggerContext respectively | ||
var ( | ||
_ onelog.Logger = (*Adapter)(nil) | ||
_ onelog.LoggerContext = (*Context)(nil) | ||
) | ||
|
||
type ( | ||
Adapter struct{} | ||
|
||
Context struct{} | ||
) | ||
|
||
func NewAdapter() onelog.Logger { return &Adapter{} } | ||
|
||
func (a *Adapter) Debug() onelog.LoggerContext { return &Context{} } | ||
func (a *Adapter) Info() onelog.LoggerContext { return &Context{} } | ||
func (a *Adapter) Warn() onelog.LoggerContext { return &Context{} } | ||
func (a *Adapter) Error() onelog.LoggerContext { return &Context{} } | ||
func (a *Adapter) Fatal() onelog.LoggerContext { return &Context{} } | ||
|
||
func (c *Context) Str(_, _ string) onelog.LoggerContext { return c } | ||
func (c *Context) Strs(_ string, _ []string) onelog.LoggerContext { return c } | ||
func (c *Context) Int(_ string, _ int) onelog.LoggerContext { return c } | ||
func (c *Context) Ints(_ string, _ []int) onelog.LoggerContext { return c } | ||
func (c *Context) Int8(_ string, _ int8) onelog.LoggerContext { return c } | ||
func (c *Context) Ints8(_ string, _ []int8) onelog.LoggerContext { return c } | ||
func (c *Context) Int16(_ string, _ int16) onelog.LoggerContext { return c } | ||
func (c *Context) Ints16(_ string, _ []int16) onelog.LoggerContext { return c } | ||
func (c *Context) Int32(_ string, _ int32) onelog.LoggerContext { return c } | ||
func (c *Context) Ints32(_ string, _ []int32) onelog.LoggerContext { return c } | ||
func (c *Context) Int64(_ string, _ int64) onelog.LoggerContext { return c } | ||
func (c *Context) Ints64(_ string, _ []int64) onelog.LoggerContext { return c } | ||
func (c *Context) Uint(_ string, _ uint) onelog.LoggerContext { return c } | ||
func (c *Context) Uints(_ string, _ []uint) onelog.LoggerContext { return c } | ||
func (c *Context) Uint8(_ string, _ uint8) onelog.LoggerContext { return c } | ||
func (c *Context) Uints8(_ string, _ []uint8) onelog.LoggerContext { return c } | ||
func (c *Context) Uint16(_ string, _ uint16) onelog.LoggerContext { return c } | ||
func (c *Context) Uints16(_ string, _ []uint16) onelog.LoggerContext { return c } | ||
func (c *Context) Uint32(_ string, _ uint32) onelog.LoggerContext { return c } | ||
func (c *Context) Uints32(_ string, _ []uint32) onelog.LoggerContext { return c } | ||
func (c *Context) Uint64(_ string, _ uint64) onelog.LoggerContext { return c } | ||
func (c *Context) Uints64(_ string, _ []uint64) onelog.LoggerContext { return c } | ||
func (c *Context) Float32(_ string, _ float32) onelog.LoggerContext { return c } | ||
func (c *Context) Floats32(_ string, _ []float32) onelog.LoggerContext { return c } | ||
func (c *Context) Float64(_ string, _ float64) onelog.LoggerContext { return c } | ||
func (c *Context) Floats64(_ string, _ []float64) onelog.LoggerContext { return c } | ||
func (c *Context) Bool(_ string, _ bool) onelog.LoggerContext { return c } | ||
func (c *Context) Bools(_ string, _ []bool) onelog.LoggerContext { return c } | ||
func (c *Context) Time(_ string, _ time.Time) onelog.LoggerContext { return c } | ||
func (c *Context) Times(_ string, _ []time.Time) onelog.LoggerContext { return c } | ||
func (c *Context) Dur(_ string, _ time.Duration) onelog.LoggerContext { return c } | ||
func (c *Context) Durs(_ string, _ []time.Duration) onelog.LoggerContext { return c } | ||
func (c *Context) IPAddr(_ string, _ net.IP) onelog.LoggerContext { return c } | ||
func (c *Context) IPPrefix(_ string, _ net.IPNet) onelog.LoggerContext { return c } | ||
func (c *Context) MACAddr(_ string, _ net.HardwareAddr) onelog.LoggerContext { return c } | ||
func (c *Context) Err(_ error) onelog.LoggerContext { return c } | ||
func (c *Context) Errs(_ string, _ []error) onelog.LoggerContext { return c } | ||
func (c *Context) AnErr(_ string, _ error) onelog.LoggerContext { return c } | ||
func (c *Context) Any(_ string, _ any) onelog.LoggerContext { return c } | ||
func (c *Context) Fields(_ onelog.Fields) onelog.LoggerContext { return c } | ||
|
||
func (c *Context) Msg(_ string) {} | ||
func (c *Context) Msgf(_ string, _ ...any) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Package nopadapter implements a no-operation (nop) adapter for the Go onelog library. | ||
The nopadapter package is useful when you want to integrate with the onelog library, but do not require any backend | ||
processing for the logs. It can be used as a placeholder for a real logger, or as a way to disable logging in your | ||
application. | ||
Example: | ||
log := nopadapter.NewAdapter() | ||
log.Debug().Str("debug", "message").Msg("This debug message will not be logged anywhere") | ||
log.Info().Str("info", "message").Msg("This info message will not be logged anywhere") | ||
Note that as it is a no-operation (nop) implementation, no actual logging will be performed. | ||
*/ | ||
package nopadapter |