https://github.com/kaatinga/dummylogger
a summy logger to add to any package that must log something somewhere
https://github.com/kaatinga/dummylogger
Last synced: 5 months ago
JSON representation
a summy logger to add to any package that must log something somewhere
- Host: GitHub
- URL: https://github.com/kaatinga/dummylogger
- Owner: kaatinga
- License: mit
- Created: 2024-03-16T11:15:20.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-14T13:10:57.000Z (almost 2 years ago)
- Last Synced: 2024-07-14T14:56:50.767Z (almost 2 years ago)
- Language: Go
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/kaatinga/dummylogger/actions/workflows/test.yml)
# dummylogger
A dummy logger for a custom package.
## Usage
Use the custom logger in your package.
```go
import (
"github.com/kaatinga/dummylogger"
)
var log = dummylogger.Get()
func Init(logger dummylogger.I) {
dummylogger.Set(logger)
}
```
Use it where you need it in the package.
```go
func main() {
log().Errorf("This is an error message")
}
```
Create a custom logger in your project.
```go
type customLogger bool
var CustomLogger = customLogger(true)
func (customLogger) Errorf(format string, v ...interface{}) {
logger.Error().Msgf(format, v...)
}
```
Pass the custom logger to init the package.
```go
import (
"github.com/yourname/yourpackage"
)
func main() {
yourpackage.Init(CustomLogger)
}
```