/logsymbols

golang package with simple log symbols

Primary LanguageGoMIT LicenseMIT

Tests Go Report Card Go Reference License Coverage

log symbols

Colored symbols for various log levels Includes fallbacks for Windows CMD which only supports a limited character set.

Linux/Mac

logsymbols on Linux

Windows

logsymbols on Windows

Install

$ go get github.com/guumaster/logsymbols

Usage

Basic example

package main

import (
  "fmt"
  "github.com/guumaster/logsymbols"
)

func main() {
    fmt.Println(logsymbols.Success, "Finished successfully!")
    fmt.Println(logsymbols.Error, "Something broke")

    // On good OSes:  ✔ Finished successfully!
    //                ✖ Something broke

    // On Windows:    √ Finished successfully!
    //                × Something broke
}

Forcing colors

logsymbols will autodetect if its not in TTY mode and remove all colors. You can force color output with this example:

  	logsymbols.ForceColors()
    fmt.Println(logsymbols.Success, "Finished successfully!")

    // Terminal Output:  ✔ Finished successfully!
    // Redirected Output:       ^[[1;32m✔^[[0m Finished successfully!
}

Fallback Symbols

logsymbols will autodetect which OS is running and will change to the proper icons on Windows.

You also can get the fallback symbols with this example:

    fallback := logsymbols.FallbackSymbols()
    fmt.Println(fallback.Success, "Finished successfully!")

    // Output:  √ Finished successfully!
}

More examples

See example folder

Ported from npm version

Related

Author(s)

If you like this tool and think is worth it, you can invite me a coffee:

paypal.me/guumaster ko-fi.com/guumaster

LICENSE

MIT license