eyes

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

README

Eyes

Eyes is a lightweight, easy-to-use logging library for Go with colored output powered by fatih/color. It provides easy-to-use functions like Info, Warn, Success, and Fatal with configurable prefixes and timestamps, ideal for CLI apps and system tools

Features

  • Easy-to-use logging functions: Info, Warn, Success, Fatal
  • Configurable prefix templates with placeholders:
    • {display_name} – your logger name
    • {timestamp} – current time
    • {log_level} – log level (INFO, WARN, SUCCESS, FATAL)
  • Configurable timestamp format
  • Per-level color schemes

Installation

go get github.com/Aperture-OS/eyes

Usage

package main

import (
    "github.com/Aperture-OS/eyes"
    "github.com/fatih/color"
    "time"
)

func main() {
    // Configure the logger
    eyes.SetLoggerConfiguration(eyes.LoggerConfiguration{
        DisplayName:     "DEBUG",
        PrefixTemplate:  "[{display_name}] {timestamp} {log_level} ",
        TimestampFormat: "15:04:05",
        InfoTextColor:    color.New(color.FgCyan),
        WarnTextColor:    color.New(color.FgYellow),
        SuccessTextColor: color.New(color.FgGreen),
        FatalTextColor:   color.New(color.FgRed, color.Bold),
    })

    eyes.Info("This is an info message")
    eyes.Warnf("This is a warning about %s", "disk space")
    eyes.Successln("Operation completed successfully")
    // eyes.Fatal("Fatal error occurred") // will exit the program
}

License

This project is licensed under the GNU General Public License v3.0. See LICENSE for details. Copyright © ApertureOS 2025-2026

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error added in v1.1.0

func Error(arguments ...any)

Error prints an error message and doesnt exit.

func Errorf added in v1.1.0

func Errorf(format string, arguments ...any)

Errorf prints a formatted error message and doesnt exit

func Errorln added in v1.1.0

func Errorln(arguments ...any)

Errorln prints an error message followed by a newline and doesnt exit

func Fatal

func Fatal(arguments ...any)

Fatal prints a fatal error message and exits with status code 1.

func Fatalf

func Fatalf(format string, arguments ...any)

Fatalf prints a formatted fatal error message and exits with status code 1.

func Fatalln

func Fatalln(arguments ...any)

Fatalln prints a fatal error message followed by a newline and exits with status code 1.

func Info

func Info(arguments ...any)

Info prints an informational message using default formatting.

func Infof

func Infof(format string, arguments ...any)

Infof prints a formatted informational message.

func Infoln

func Infoln(arguments ...any)

Infoln prints an informational message followed by a newline.

func SetLoggerConfiguration

func SetLoggerConfiguration(config LoggerConfiguration)

SetLoggerConfiguration Replaces the global logger configuration example:

eyes.SetLoggerConfiguration(eyes.LoggerConfiguration{
	DisplayName:     "DEBUG",  // goes in [DISPLAYNAME] 15:05:04 FATAL: Error message
	PrefixTemplate:  "[{display_name}] {timestamp} {log_level} ", // note the space at the end
	TimestampFormat: "15:04:05", // which is: time.Now().Format("TimestampFormat HERE")

	InfoTextColor:    color.New(color.FgCyan),   // use any color from github.com/fatih/color
	WarnTextColor:    color.New(color.FgYellow), // usually you should use ansi-16 colors
	SuccessTextColor: color.New(color.FgGreen),
	FatalTextColor:   color.New(color.FgRed, color.Bold),
})

func Success

func Success(arguments ...any)

Success prints a success message.

func Successf

func Successf(format string, arguments ...any)

Successf prints a formatted success message.

func Successln

func Successln(arguments ...any)

Successln prints a success message followed by a newline.

func Warn

func Warn(arguments ...any)

Warn prints a warning message.

func Warnf

func Warnf(format string, arguments ...any)

Warnf prints a formatted warning message.

func Warnln

func Warnln(arguments ...any)

Warnln prints a warning message followed by a newline.

Types

type LoggerConfiguration

type LoggerConfiguration struct {
	// DisplayName is substituted into {display_name}
	// Example: "DEBUG", "Blink", "Aperture"
	DisplayName string

	// PrefixTemplate defines the exact text printed
	// before every log message.
	//
	// Supported placeholders:
	//   {display_name} -> DisplayName
	//   {timestamp}    -> current time
	//   {log_level}    -> INFO, WARN, SUCCESS, FATAL
	PrefixTemplate string

	// TimestampFormat controls how {timestamp} is rendered
	// Uses time.Format layout strings
	TimestampFormat string

	// Colors used for each log level
	InfoTextColor    *color.Color
	WarnTextColor    *color.Color
	SuccessTextColor *color.Color
	FatalTextColor   *color.Color
}

LoggerConfiguration Holds all user-configurable settings for the logger

Jump to

Keyboard shortcuts

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