go-logr implementation with pterm

plogr

Go version Version Go Report Card Codecov

go-logr implementation with pterm

Usage

See examples

Add more colors and levels

By default, only level 0 (info) and level 1 (debug) are supported.

While go-logr doesn't have names for logging levels ("info", "warning", etc), pterm does. Both libraries agree that verbosity is increased with higher numeric logging level. For pterm however, one could argue that their "Warning" and "Success" levels have lower verbosity than "Info". If you like to customize the levels or styling, you could do something like this:

func main() {
	sink := plogr.NewPtermSink()
	sink.LevelPrinters[3] = pterm.Debug
	sink.LevelPrinters[2] = plogr.DefaultLevelPrinters[0]
	sink.LevelPrinters[1] = pterm.Success
	sink.LevelPrinters[0] = pterm.Warning

	logger := logr.New(sink)
	logger.V(0).WithName("main").Info("Warning message")
	logger.V(1).WithName("app").Info("Success message")
	logger.V(2).WithName("database").Info("Info message", "key", "value")
	logger.V(3).WithName("controller").Info("Debug message")
}

example output

That means whenever you want to show informational messages, you'd have to set the logging level to 2 in your code base. Alternatively, without breaking the code base, append levels like success to the LevelPrinters to your desired level, disregarding the verbosity increase though.

The error printer can be customized as well, but it has its own field.

Owner
Chris
Cannot decide between Dev and Ops, so I'll do both!
Chris
Comments
  • Update module go to 1.19 - autoclosed

    Update module go to 1.19 - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | go (source) | golang | minor | 1.16 -> 1.19 |


    Release Notes

    golang/go

    v1.19.4

    v1.19.3

    v1.19.2

    v1.19.1

    v1.19.0

    v1.18.9

    v1.18.8

    v1.18.7

    v1.18.6

    v1.18.5

    v1.18.4

    v1.18.3

    v1.18.2

    v1.18.1

    v1.18.0

    v1.17.13

    v1.17.12

    v1.17.11

    v1.17.10

    v1.17.9

    v1.17.8

    v1.17.7

    v1.17.6

    v1.17.5

    v1.17.4

    v1.17.3

    v1.17.2

    v1.17.1

    v1.17.0


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Remove Fallback printer

    Remove Fallback printer

    Summary

    Now, each level has to be explicitly enabled. No longer are debug messages being printed if the level isn't explicitly enabled.

    Checklist

    • [x] Categorize the PR by setting a good title and adding one of the labels: fix, enhancement, documentation, change, breaking, dependency as they show up in the changelog
    • [x] Update documentation.
    • [x] Update tests.
  • Disable debug printer by default, update prefix

    Disable debug printer by default, update prefix

    Summary

    • Disables the printer for log level 1 by default
    • Updates the text of the prefix from DEBUG to DBUG/<level>

    Checklist

    • [x] Categorize the PR by setting a good title and adding one of the labels: fix, enhancement, documentation, change, breaking, dependency as they show up in the changelog
    • [x] Update documentation.
    • [x] Update tests.
  • Update module github.com/pterm/pterm to v0.12.51

    Update module github.com/pterm/pterm to v0.12.51

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/pterm/pterm | require | patch | v0.12.50 -> v0.12.51 |


    Release Notes

    pterm/pterm

    v0.12.51

    Compare Source

    What's Changed

    Fixes 🔧

    New Contributors

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.50...v0.12.51


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/stretchr/testify to v1.8.1

    Update module github.com/stretchr/testify to v1.8.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/stretchr/testify | require | patch | v1.8.0 -> v1.8.1 |


    Release Notes

    stretchr/testify

    v1.8.1

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/pterm/pterm to v0.12.50

    Update module github.com/pterm/pterm to v0.12.50

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/pterm/pterm | require | patch | v0.12.48 -> v0.12.50 |


    Release Notes

    pterm/pterm

    v0.12.50

    Compare Source

    What's Changed

    Fixes 🔧
    Other Changes

    New Contributors

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.49...v0.12.50

    v0.12.49

    Compare Source

    [v0.12.49] - 2022-10-03


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/pterm/pterm to v0.12.48

    Update module github.com/pterm/pterm to v0.12.48

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/pterm/pterm | require | patch | v0.12.46 -> v0.12.48 |


    Release Notes

    pterm/pterm

    v0.12.48

    Compare Source

    What's Changed

    Exciting New Features 🎉

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.47...v0.12.48

    v0.12.47

    Compare Source

    What's Changed

    Exciting New Features 🎉
    Other Changes

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.46...v0.12.47


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/pterm/pterm to v0.12.46

    Update module github.com/pterm/pterm to v0.12.46

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/pterm/pterm | require | patch | v0.12.43 -> v0.12.46 |


    Release Notes

    pterm/pterm

    v0.12.46

    Compare Source

    What's Changed

    Exciting New Features 🎉
    Fixes 🔧
    Other Changes

    New Contributors

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.45...v0.12.46

    v0.12.45

    Compare Source

    Bug Fixes
    • make sure the interactive printers can cleanup after Ctrl+C
    • the interactive confirm answers should match the confirm/reject text
    Test
    • add tests for custom answers

    v0.12.44

    Compare Source

    [v0.12.44] - 2022-07-22


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/pterm/pterm to v0.12.43

    Update module github.com/pterm/pterm to v0.12.43

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/pterm/pterm | require | patch | v0.12.42 -> v0.12.43 |


    Release Notes

    pterm/pterm

    v0.12.43

    Compare Source

    What's Changed

    Fixes 🔧

    New Contributors

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.42...v0.12.43


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/pterm/pterm to v0.12.42

    Update module github.com/pterm/pterm to v0.12.42

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/pterm/pterm | require | patch | v0.12.41 -> v0.12.42 |


    Release Notes

    pterm/pterm

    v0.12.42

    Compare Source

    PTerm got its own docs site! 📖

    --> https://docs.pterm.sh <--

    We now feature interactive printers! 🥳🎉

    PTerm interactive multiselect menu

    More here: https://docs.pterm.sh/printers/interactive

    What's Changed

    Exciting New Features 🎉
    Other Changes

    Full Changelog: https://github.com/pterm/pterm/compare/v0.12.41...v0.12.42


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

  • Update module github.com/stretchr/testify to v1.8.0

    Update module github.com/stretchr/testify to v1.8.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/stretchr/testify | require | minor | v1.7.3 -> v1.8.0 |


    Release Notes

    stretchr/testify

    v1.8.0

    Compare Source

    v1.7.5

    Compare Source

    v1.7.4

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

Related tags
Implementation of do255e and do255s in Go

Go Implementation of do255e and do255s This is a plain Go implementation of do255e and do255s. It is considered secure; all relevant functions should

Aug 15, 2022
Go implementation of the Heaven's Gate technique
Go implementation of the Heaven's Gate technique

gopherheaven is a Go implementation of the classic Heaven's Gate technique originally published by roy g biv on VX Heaven in 2009. gopherheaven can be used as an evasion technique to directly call 64-bit code from a 32-bit process.

Dec 20, 2022
Lightweight, Simple, Quick, Thread-Safe Golang Stack Implementation

stack Lightweight, Simple, Quick, Thread-Safe Golang Stack Implementation Purpose Provide a fast, thread safe, and generic Golang Stack API with minim

May 3, 2022
Optimal implementation of ordered maps for Golang - ie maps that remember the order in which keys were inserted.

Goland Ordered Maps Same as regular maps, but also remembers the order in which keys were inserted, akin to Python's collections.OrderedDicts. It offe

Jan 3, 2023
An idiomatic Go implementation of Leaky bucket.

lbucket lbucket is an idiomatic Go leaky bucket implementation. The library make use of plain old Go stdlib; in other words, there are no third-party

Apr 17, 2022
A faster RWLock primitive in Go, 2-3 times faster than RWMutex. A Go implementation of concurrency control algorithm in paper

Go Left Right Concurrency A Go implementation of the left-right concurrency control algorithm in paper <Left-Right - A Concurrency Control Technique w

Jan 6, 2023
Go implementation of the geodesic routines from GeographicLib
Go implementation of the geodesic routines from GeographicLib

geodesic This package is a Go implementation of the geodesic routines from GeographicLib. Features Pure Go implementation Distance calculations with n

Dec 23, 2022
Reference go implementation of globaldce protocol

globaldce-go This is the reference implementation of the command line interface of globaldce coded in the go programming language. This project is sti

Nov 8, 2021
Go implementation Welford’s method for one-pass variance computation

Welford - Online method of calculating variance and standard deviation Go implementation Welford’s method for one-pass variance computation with D. H.

Jan 6, 2023
Sliding window counters Redis rate limiting implementation for Golang

Sliding window counters Redis rate limiting implementation for Golang (Based on the Figma API rate limit algorithm)

Dec 21, 2022
Implementation for validating the NZ COVID Pass.

NZCP validator Validates NZCP passes according to https://nzcp.covid19.health.nz. Example See example_test.go and tests for more examples. func Exampl

Dec 20, 2021
Generic Free List implementation to reuse memory and avoid allocations

gofl GOFL provides a Generic Free List implementation for Go. Installation This

Oct 17, 2022
yaml-patch is a version of Evan Phoenix's json-patch, which is an implementation of JSON Patch, directly transposed to YAML

yaml-patch yaml-patch is a version of Evan Phoenix's json-patch, which is an implementation of JavaScript Object Notation (JSON) Patch, directly trans

Jan 15, 2022
A pure Golang implementation of Rockchip rknand vendor storage interface.

go-rkvendorstorage A pure Golang implementation of Rockchip rknand vendor storage interface. Usage package main import ( "fmt" "github.com/jamesits

Nov 8, 2022
Golang 1.18+ Generics implementation of Set methods

Golang Generics: Set A golang 1.18+ implementation of Set using Go generics Installation $ go get -u github.com/chrispappas/golang-generics-set Quick

Oct 26, 2022
A logr LogSink implementation using Zerolog

Zerologr A logr LogSink implementation using Zerolog. Usage import ( "os" "github.com/go-logr/logr" "github.com/hn8/zerologr" "github

Nov 17, 2022
A logr LogSink implementation using bytes.Buffer

buflogr A logr LogSink implementation using bytes.Buffer. Usage import ( "bytes" "fmt" "github.com/go-logr/logr" "github.com/tonglil/buflogr" )

Jan 6, 2023
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.

?? PTerm | Pretty Terminal Printer A golang module to print pretty text Show Demo Code PTerm.sh | Installation | Documentation | Quick Start | Example

Dec 27, 2022
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

✨ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more ?? It's completely configurable and 100% cross-platform compatible.

Jan 1, 2023
Benchmark - Benchmark of logr implementations

Benchmark of logr implementations Implementations a function (can bridge to non-

Nov 6, 2022