Download Latest Version v2.0.0 source code.zip (57.5 kB)
Email in envelope

Get an email when there's a new version of Log

Home / v0.4.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2024-03-21 2.6 kB
v0.4.0 source code.tar.gz 2024-03-21 28.5 kB
v0.4.0 source code.zip 2024-03-21 52.2 kB
Totals: 3 Items   83.3 kB 0

Custom Levels

With this release of Log, you can now style your custom level to your liking!

:::go
// Define a new level
const SuccessLevel = log.InfoLevel + 1

// Create a style
styles := log.DefaultStyles()
styles.Levels[SuccessLevel] = lipgloss.NewStyle().
    SetString("SUCCESS").
    Bold(true).
    Foreground(lipgloss.Color("42"))

// Set the styles on the default logger
log.SetStyles(styles)

// Define your custom func
func Success(msg string, args ...any) {
    log.Default().Log(SuccessLevel, msg, args...)
}

Along with that, this release includes some important bug fixes detailed below.

## Changelog ### New Features * 2338a13b1bd15b2545de614b50ce123b12ff0af3: feat: expose log function (#95) (@aymanbagabas) ### Bug fixes * 28193306e6f5a221d00a74fa6e8683ea10ae06be: fix: lazy init default logger (#111) (@caarlos0) ### Dependency updates * bcd47385a62a19911e9970bcc96a3431af338160: feat(deps): bump github.com/charmbracelet/lipgloss from 0.9.1 to 0.10.0 (#112) (@dependabot[bot]) * 976db2be8ef2dad2071a6f061ea20b3e0df90c54: feat(deps): bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#108) (@dependabot[bot]) ### Documentation updates * 87252e4b6fe8ac6e0378a5f6bd10c81cf016478f: docs: Replace function with func in README sample code (@szktkfm) * ac0e6b17de4d9fb40f924721b9be2551b6a3a5b1: docs: direct users to library API (#73) (@bashbunni) * 9d04d2b741a63f044858c77785d81acdd04974c1: docs: style customization updated (#106) (@ssantoshp) ### Other work * a4246434f75cb530c9e1ac28656f7d8e887b08f8: Create CODEOWNERS (@maaslalani) * fd1729ad8eb8badce23ad62a2050f33e93b82fd8: Options.CallerFormatter documentation issue (#100) (@pythonian23) * f2cb6b676b58002dfe178158f3d53017e5869de2: ci: test on go define in go.mod (#102) (@caarlos0) * d23bea6596cacd0141af226b09cc08778a521204: fix!: respect time function (#115) (@aymanbagabas) * 7a3834f9b3670792499ec4fc7e4610a22c8a5936: slog: Don't log if not enabled at level (#103) (@imjasonh)

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

Source: README.md, updated 2024-03-21