Hallucinate a bunch of docs
This commit is contained in:
12
colors.go
12
colors.go
@@ -1,3 +1,7 @@
|
||||
// Package cylogger provides ANSI color constants and utilities for terminal output.
|
||||
// This file contains all the color constants used by the logger for styling log messages.
|
||||
// It includes regular colors, bold colors, underlined colors, background colors,
|
||||
// high intensity colors, and utility functions for generating random colors.
|
||||
package cylogger
|
||||
|
||||
import (
|
||||
@@ -122,6 +126,14 @@ var colors = []int{22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 3
|
||||
var colorsIndex int = -1
|
||||
var shuffled bool
|
||||
|
||||
// GenerateRandomAnsiColor generates a random ANSI color code from a curated set of colors.
|
||||
// The colors are shuffled once and then cycled through in order.
|
||||
// This is useful for generating unique colors for different log sources or components.
|
||||
// The function returns a formatted ANSI color code that can be used for text styling.
|
||||
// Example:
|
||||
//
|
||||
// color := cylogger.GenerateRandomAnsiColor()
|
||||
// fmt.Printf("%sColored text%s", color, cylogger.Reset)
|
||||
func GenerateRandomAnsiColor() string {
|
||||
if !shuffled {
|
||||
rand.Shuffle(len(colors), func(i int, j int) {
|
||||
|
||||
Reference in New Issue
Block a user