Browse Source

[R4R] libs/log: add year to log format (#2707)

* add year to log format

* update documentation
pull/2735/head
yutianwu 6 years ago
committed by Ethan Buchman
parent
commit
60437953ac
3 changed files with 8 additions and 7 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +4
    -4
      docs/architecture/adr-001-logging.md
  3. +3
    -3
      libs/log/tmfmt_logger.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -91,6 +91,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [crypto/ed25519] [\#2558](https://github.com/tendermint/tendermint/issues/2558) Switch to use latest `golang.org/x/crypto` through our fork at - [crypto/ed25519] [\#2558](https://github.com/tendermint/tendermint/issues/2558) Switch to use latest `golang.org/x/crypto` through our fork at
github.com/tendermint/crypto github.com/tendermint/crypto
- [tools] [\#2238](https://github.com/tendermint/tendermint/issues/2238) Binary dependencies are now locked to a specific git commit - [tools] [\#2238](https://github.com/tendermint/tendermint/issues/2238) Binary dependencies are now locked to a specific git commit
- [libs/log] [\#2706](https://github.com/tendermint/tendermint/issues/2706) Add year to log format
### BUG FIXES: ### BUG FIXES:
- [autofile] [\#2428](https://github.com/tendermint/tendermint/issues/2428) Group.RotateFile need call Flush() before rename (@goolAdapter) - [autofile] [\#2428](https://github.com/tendermint/tendermint/issues/2428) Group.RotateFile need call Flush() before rename (@goolAdapter)


+ 4
- 4
docs/architecture/adr-001-logging.md View File

@ -52,13 +52,13 @@ On top of this interface, we will need to implement a stdout logger, which will
Many people say that they like the current output, so let's stick with it. Many people say that they like the current output, so let's stick with it.
``` ```
NOTE[04-25|14:45:08] ABCI Replay Blocks module=consensus appHeight=0 storeHeight=0 stateHeight=0
NOTE[2017-04-25|14:45:08] ABCI Replay Blocks module=consensus appHeight=0 storeHeight=0 stateHeight=0
``` ```
Couple of minor changes: Couple of minor changes:
``` ```
I[04-25|14:45:08.322] ABCI Replay Blocks module=consensus appHeight=0 storeHeight=0 stateHeight=0
I[2017-04-25|14:45:08.322] ABCI Replay Blocks module=consensus appHeight=0 storeHeight=0 stateHeight=0
``` ```
Notice the level is encoded using only one char plus milliseconds. Notice the level is encoded using only one char plus milliseconds.
@ -155,14 +155,14 @@ Important keyvals should go first. Example:
``` ```
correct correct
I[04-25|14:45:08.322] ABCI Replay Blocks module=consensus instance=1 appHeight=0 storeHeight=0 stateHeight=0
I[2017-04-25|14:45:08.322] ABCI Replay Blocks module=consensus instance=1 appHeight=0 storeHeight=0 stateHeight=0
``` ```
not not
``` ```
wrong wrong
I[04-25|14:45:08.322] ABCI Replay Blocks module=consensus appHeight=0 storeHeight=0 stateHeight=0 instance=1
I[2017-04-25|14:45:08.322] ABCI Replay Blocks module=consensus appHeight=0 storeHeight=0 stateHeight=0 instance=1
``` ```
for that in most cases you'll need to add `instance` field to a logger upon creating, not when u log a particular message: for that in most cases you'll need to add `instance` field to a logger upon creating, not when u log a particular message:


+ 3
- 3
libs/log/tmfmt_logger.go View File

@ -84,13 +84,13 @@ func (l tmfmtLogger) Log(keyvals ...interface{}) error {
// Form a custom Tendermint line // Form a custom Tendermint line
// //
// Example: // Example:
// D[05-02|11:06:44.322] Stopping AddrBook (ignoring: already stopped)
// D[2016-05-02|11:06:44.322] Stopping AddrBook (ignoring: already stopped)
// //
// Description: // Description:
// D - first character of the level, uppercase (ASCII only) // D - first character of the level, uppercase (ASCII only)
// [05-02|11:06:44.322] - our time format (see https://golang.org/src/time/format.go)
// [2016-05-02|11:06:44.322] - our time format (see https://golang.org/src/time/format.go)
// Stopping ... - message // Stopping ... - message
enc.buf.WriteString(fmt.Sprintf("%c[%s] %-44s ", lvl[0]-32, time.Now().Format("01-02|15:04:05.000"), msg))
enc.buf.WriteString(fmt.Sprintf("%c[%s] %-44s ", lvl[0]-32, time.Now().Format("2016-01-02|15:04:05.000"), msg))
if module != unknown { if module != unknown {
enc.buf.WriteString("module=" + module + " ") enc.buf.WriteString("module=" + module + " ")


Loading…
Cancel
Save