https://github.com/elliotxx/clilog
A Go library for simple and pretty command-line logging
https://github.com/elliotxx/clilog
Last synced: 6 months ago
JSON representation
A Go library for simple and pretty command-line logging
- Host: GitHub
- URL: https://github.com/elliotxx/clilog
- Owner: elliotxx
- License: mit
- Created: 2025-02-08T04:24:34.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-08T08:21:35.000Z (8 months ago)
- Last Synced: 2025-02-08T08:27:14.702Z (8 months ago)
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# clilog
[](https://goreportcard.com/report/github.com/elliotxx/clilog)
[](https://godoc.org/github.com/elliotxx/clilog)
[](https://github.com/elliotxx/clilog/blob/main/LICENSE)A Go library for simple and pretty command-line logging

## Features
- Hierarchical logging with indentation
- Built-in log levels (Debug/Info/Warn/Success/Error)
- Customizable prefixes and colors
- Bold text formatting
- Verbose mode control
- Color output toggle## Installation
```bash
go get github.com/elliotxx/clilog
```## Usage
```go
package mainimport (
"github.com/elliotxx/clilog"
)func main() {
log.L(1).P("→").C(log.ColorCyan).Log("Item 1")
}
```## Examples
### Basic Logging
```go
log.Info("Application started")
log.Warn("High memory usage detected")
log.Success("User login successful")
log.Error("Database connection failed")
```### Hierarchical Logging
```go
log.Info("Processing order %d", 1234).
L(1).P("→").C(log.ColorCyan).Log("Validating items").
L(2).Info("Checking inventory").
L(2).Success("Stock available").
L(1).P("✓").C(log.ColorGreen).Log("Payment processing").
L(1).Error("Shipping address invalid")
```### Progress Indicator
```go
// Initialize progress bar
progress := log.New().L(1).P("▰").C(log.ColorBlue)for i := 0; i <= 10; i++ {
progress.Log("Loading: %s", strings.Repeat("▰", i))
time.Sleep(300 * time.Millisecond)
}
```### Formatted Data Display
```go
log.Info("User Profile:").
L(1).Log("Name: %s", log.Bold("Alice")).
L(1).Log("Email: %s", log.Bold("alice@example.com")).
L(1).Log("Balance: %s", log.Bold("$1,234.56"))
```### Disable Color Output
```go
log.SetNoColor(true)
log.Info("Running in CI environment")
```## 👥 Who's using it
- [osp](https://github.com/elliotxx/osp)
## 🤝 Contributing
We welcome all forms of contributions! Whether it's new features, documentation improvements, or bug fixes. See our [Contributing Guide](CONTRIBUTING.md) for details.
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.