aurora

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 11 Imported by: 0

README

Aurora

Beautiful, enterprise-grade console logging for Go.

Go Reference Go Report Card

Aurora is a zero-dependency logging library that makes your terminal output stunning. Features gradient-colored ASCII banners, structured logging with tree-style output, progress bars, spinners, tables, and more.

Installation

go get github.com/Summaw/aurora

Quick Start

package main

import "github.com/Summaw/aurora"

func main() {
    aurora.Banner("MYAPP").
        Gradient("cyberpunk").
        Tagline("My Application").
        Version("v1.0.0").
        Render()

    log := aurora.New()

    log.Info("Application started").Send()
    log.Success("Database connected").Str("host", "localhost").Send()
    log.Warn("High memory usage").Int("percent", 85).Send()
    log.Error("Connection failed").Err(err).Send()
}

Features

ASCII Art Banners
aurora.Banner("AURORA").
    Font("block").           // block, slant, minimal
    Gradient("cyberpunk").   // 20+ built-in gradients
    Tagline("My App").
    Version("v1.0.0").
    Border("rounded").       // rounded, sharp, double, heavy, ascii
    Render()
Structured Logging
log := aurora.New()

log.Info("Request completed").
    Str("method", "POST").
    Str("path", "/api/users").
    Int("status", 201).
    Dur("latency", time.Since(start)).
    Send()

Output:

  14:23:01.123  ● INFO  Request completed
                ├─ method: POST
                ├─ path: /api/users
                ├─ status: 201
                └─ latency: 23.45ms
Log Levels
log.Trace("Trace message")       // ◦ gray
log.Debug("Debug message")       // ● dark gray
log.Info("Info message")         // ● blue
log.Success("Success message")   // ✓ green
log.Warn("Warning message")      // ⚠ yellow
log.Error("Error message")       // ✖ red
log.Fatal("Fatal message")       // 💀 bright red (exits)
Configuration
log := aurora.New(
    aurora.WithLevel(aurora.DebugLevel),
    aurora.WithCaller(true),
    aurora.WithJSON(true),  // JSON output for production
)
UI Components
Tables
aurora.Table(
    []string{"Service", "Status", "Latency"},
    [][]string{
        {"api", "● Healthy", "12ms"},
        {"db", "● Healthy", "3ms"},
    },
).Gradient("mint").Render()
Progress Bars
bar := aurora.Progress("Downloading", 100)
for i := 0; i <= 100; i++ {
    bar.Set(i)
    time.Sleep(50 * time.Millisecond)
}
bar.Done()
Spinners
spin := aurora.Spin("Connecting...")
// ... work ...
spin.Success("Connected!")
Dividers & Key-Value Display
aurora.Divider("Configuration").Render()
aurora.KV(map[string]any{
    "Environment": "production",
    "Version": "1.0.0",
}).Render()
Built-in Gradients

aurora, sunset, ocean, neon, cyberpunk, miami, fire, forest, galaxy, retro, mint, peach, lavender, gold, ice, blood, matrix, vaporwave, rainbow, terminal, rose, sky

Custom Gradients
aurora.Banner("APP").GradientRGB(
    aurora.RGB(255, 0, 128),
    aurora.RGB(0, 255, 255),
).Render()

aurora.Banner("APP").GradientMulti(
    "#ff0000", "#ff7f00", "#ffff00", "#00ff00",
).Render()

Project Structure

aurora/
├── aurora.go           # Main public API
├── logger.go           # Logger implementation
├── entry.go            # Entry/field chaining
├── level.go            # Log levels
├── config.go           # Configuration
├── options.go          # Functional options
├── pkg/
│   ├── banner/         # ASCII banner system
│   ├── color/          # Color & gradient engine
│   └── style/          # UI components
├── middleware/         # HTTP middleware
├── docs/               # Documentation
└── _examples/          # Example code

License

MIT License - see LICENSE for details.

Media

_examples\basic

image

_examples\banner

image

_examples\server

image

⭐ Support Aurora

If Aurora makes your logs easier to read, debug, or demo:

  • ⭐ Star this repository to support the project

  • 🐛 Open an issue if you find a bug or have an idea

  • 🔧 Submit a PR — contributions are welcome

  • 💬 Share Aurora with your team or community

Every star helps Aurora grow and motivates future features 🚀

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLevelConfigs = map[Level]LevelConfig{
	TraceLevel: {
		Name:  "TRACE",
		Icon:  "◦",
		Color: color.RGB{R: 128, G: 128, B: 128},
		Bold:  false,
	},
	DebugLevel: {
		Name:  "DEBUG",
		Icon:  "●",
		Color: color.RGB{R: 169, G: 169, B: 169},
		Bold:  false,
	},
	InfoLevel: {
		Name:  "INFO",
		Icon:  "●",
		Color: color.RGB{R: 96, G: 165, B: 250},
		Bold:  false,
	},
	SuccessLevel: {
		Name:  "SUCCESS",
		Icon:  "✓",
		Color: color.RGB{R: 74, G: 222, B: 128},
		Bold:  true,
	},
	WarnLevel: {
		Name:  "WARN",
		Icon:  "⚠",
		Color: color.RGB{R: 251, G: 191, B: 36},
		Bold:  true,
	},
	ErrorLevel: {
		Name:  "ERROR",
		Icon:  "✖",
		Color: color.RGB{R: 248, G: 113, B: 113},
		Bold:  true,
	},
	FatalLevel: {
		Name:  "FATAL",
		Icon:  "💀",
		Color: color.RGB{R: 239, G: 68, B: 68},
		Bold:  true,
	},
	PanicLevel: {
		Name:  "PANIC",
		Icon:  "🔥",
		Color: color.RGB{R: 185, G: 28, B: 28},
		Bold:  true,
	},
}

Functions

func Banner(text string) *banner.Builder

func Box

func Box(content string) *style.BoxBuilder

func Divider

func Divider(text string) *style.DividerBuilder

func Gradient

func Gradient(name string) color.Gradient

func GradientMulti

func GradientMulti(colors ...string) color.Gradient

func GradientRGB

func GradientRGB(start, end color.RGB) color.Gradient

func Hex

func Hex(hex string) color.RGB

func KV

func KV(pairs map[string]any) *style.KVBuilder

func Progress

func Progress(label string, total int) *style.ProgressBar

func RGB

func RGB(r, g, b uint8) color.RGB

func SetLevel

func SetLevel(level Level)

func SetOutput

func SetOutput(w io.Writer)

func Spin

func Spin(message string) *style.Spinner

func Table

func Table(headers []string, rows [][]string) *style.TableBuilder

Types

type Config

type Config struct {
	Output      io.Writer
	Level       Level
	TimeFormat  string
	ShowCaller  bool
	CallerDepth int
	JSONOutput  bool
}

type Entry

type Entry struct {
	Level     Level
	Message   string
	Timestamp time.Time
	Fields    []Field
	Caller    string
	// contains filtered or unexported fields
}

func Debug

func Debug(msg string) *Entry

func Error

func Error(msg string) *Entry

func Fatal

func Fatal(msg string) *Entry

func Info

func Info(msg string) *Entry

func Success

func Success(msg string) *Entry

func Trace

func Trace(msg string) *Entry

func Warn

func Warn(msg string) *Entry

func WithFields

func WithFields(fields F) *Entry

func (*Entry) Any

func (e *Entry) Any(key string, value any) *Entry

func (*Entry) Bool

func (e *Entry) Bool(key string, value bool) *Entry

func (*Entry) Dur

func (e *Entry) Dur(key string, value time.Duration) *Entry

func (*Entry) Err

func (e *Entry) Err(err error) *Entry

func (*Entry) Field

func (e *Entry) Field(key string, value any) *Entry

func (*Entry) Float32

func (e *Entry) Float32(key string, value float32) *Entry

func (*Entry) Float64

func (e *Entry) Float64(key string, value float64) *Entry

func (*Entry) Int

func (e *Entry) Int(key string, value int) *Entry

func (*Entry) Int64

func (e *Entry) Int64(key string, value int64) *Entry

func (*Entry) Msg

func (e *Entry) Msg(msg string)

func (*Entry) Msgf

func (e *Entry) Msgf(format string, args ...any)

func (*Entry) Send

func (e *Entry) Send()

func (*Entry) Str

func (e *Entry) Str(key, value string) *Entry

func (*Entry) Time

func (e *Entry) Time(key string, value time.Time) *Entry

func (*Entry) Uint

func (e *Entry) Uint(key string, value uint) *Entry

func (*Entry) Uint64

func (e *Entry) Uint64(key string, value uint64) *Entry

func (*Entry) WithFields

func (e *Entry) WithFields(fields F) *Entry

type F

type F map[string]any

type Field

type Field struct {
	Key   string
	Value any
}

type Level

type Level int
const (
	TraceLevel Level = iota
	DebugLevel
	InfoLevel
	SuccessLevel
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
	Disabled
)

func ParseLevel

func ParseLevel(s string) Level

func (Level) Color

func (l Level) Color() color.RGB

func (Level) Icon

func (l Level) Icon() string

func (Level) String

func (l Level) String() string

type LevelConfig

type LevelConfig struct {
	Name  string
	Icon  string
	Color color.RGB
	Bold  bool
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Logger

func New

func New(opts ...Option) *Logger

func (*Logger) Ctx

func (l *Logger) Ctx(ctx context.Context) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string) *Entry

func (*Logger) EnableCaller

func (l *Logger) EnableCaller(enabled bool)

func (*Logger) Error

func (l *Logger) Error(msg string) *Entry

func (*Logger) Fatal

func (l *Logger) Fatal(msg string) *Entry

func (*Logger) Info

func (l *Logger) Info(msg string) *Entry

func (*Logger) Panic

func (l *Logger) Panic(msg string) *Entry

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

func (*Logger) SetTimeFormat

func (l *Logger) SetTimeFormat(tf string)

func (*Logger) Success

func (l *Logger) Success(msg string) *Entry

func (*Logger) Trace

func (l *Logger) Trace(msg string) *Entry

func (*Logger) Warn

func (l *Logger) Warn(msg string) *Entry

func (*Logger) With

func (l *Logger) With(key string, value any) *Logger

func (*Logger) WithFields

func (l *Logger) WithFields(fields F) *Entry

type Option

type Option func(*Config)

func WithCaller

func WithCaller(enabled bool) Option

func WithCallerDepth

func WithCallerDepth(depth int) Option

func WithJSON

func WithJSON(enabled bool) Option

func WithLevel

func WithLevel(level Level) Option

func WithOutput

func WithOutput(w io.Writer) Option

func WithTimeFormat

func WithTimeFormat(tf string) Option

Directories

Path Synopsis
_examples
banner command
basic command
server command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL