charmbracelet / log

A minimal, colorful Go logging library 🪵
MIT License
2.4k stars 67 forks source link

feat(styles): style certain keys #15

Closed aymanbagabas closed 1 year ago

aymanbagabas commented 1 year ago

Add the ability to style certain keys

Fixes: https://github.com/charmbracelet/log/issues/14

Example:

package main

import (
    "fmt"

    "github.com/charmbracelet/lipgloss"
    "github.com/charmbracelet/log"
)

func main() {
    log.KeyStyles["err"] = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff0000"))
    err := fmt.Errorf("too much sugar")
    log.Error("failed to bake cookies", "err", err)
}
codecov[bot] commented 1 year ago

Codecov Report

Merging #15 (aa7a80e) into main (6e4f0e1) will decrease coverage by 0.23%. The diff coverage is 0.00%.

:exclamation: Current head aa7a80e differs from pull request most recent head c49713d. Consider uploading reports for the commit c49713d to get more accurate results

@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
- Coverage   51.02%   50.80%   -0.23%     
==========================================
  Files          22       22              
  Lines         684      687       +3     
==========================================
  Hits          349      349              
- Misses        319      322       +3     
  Partials       16       16              
Impacted Files Coverage Δ
styles.go 0.00% <ø> (ø)
text.go 45.93% <0.00%> (-0.82%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.