Skip to content

Commit

Permalink
Updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-GV committed Apr 14, 2022
1 parent 53cc891 commit 30c9685
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/ViaQ/logerr/v2/log"
)

logger := log.NewLogger("", nil)
logger := log.NewLogger("example-logger")

logger.Info("Now logging info message")
logger.Error(errors.New("New error"), "Now logging new error")
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ logger.V(1).Info("This logger's level has been raised by 1.")
logger.V(5).Info("This logger's level has been raised by 5.")
```

_Note: The `V` method is always additive. So logger.V(1).V(1) has a logger level of 2 instead of 1._

Every log has a verbosity, which is controlled by the internal logging mechanism `logr.Sink`.

Logs are recorded in two scenarios:
Expand All @@ -51,14 +53,17 @@ _Note: As mentioned above, with no concept of an "error" log, there is no error
Logger Types:

```golang
logger := log.NewLogger("")
logger.Info("The default logger. Log verbosity is 0. Logs are written to stdout.")
logger := log.NewLogger("default-logger")
logger.Info("Log verbosity is 0. Logs are written to stdout.")

buffer := bytes.NewBuffer(nil)
options := log.Options{Writer:buffer, LogLevel: 1}
options := log.Options{
log.WithOutput(buffer),
log.WithVerbosity(1)
}

optionLogger := log.NewLogger("", options)
optionLogger.Info("Logger with options. Log verbosity is 1. Logs are written to byte buffer.")
newLogger := log.NewLogger("customized-logger", options)
newLogger.Info("Log verbosity is 1. Logs are written to byte buffer.")
```

As mentions, the `Sink` will transform messages into JSON logs. Key/value information that is included in the message is also included in the log.
Expand Down

0 comments on commit 30c9685

Please sign in to comment.