eyes

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 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)

func Errorf added in v1.1.0

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

func Errorln added in v1.1.0

func Errorln(arguments ...any)

func Fatal

func Fatal(arguments ...any)

func Fatalf

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

func Fatalln

func Fatalln(arguments ...any)

func Info

func Info(arguments ...any)

Info prints an informational message using default formatting.

func Infof

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

func Infoln

func Infoln(arguments ...any)

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)

func Successln

func Successln(arguments ...any)

func Warn

func Warn(arguments ...any)

func Warnf

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

func Warnln

func Warnln(arguments ...any)

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