logicol

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 3 Imported by: 0

README

logicol

Logicol stands for LOG In COLor. It is a wrapper around the build-in log module to add some color highlighting to log messages.

I wrote this package for the sole purpose of playing around. I'm sure there are formatting options that could be added to log that I was too lazy to read into how I could to. Instead I wrote a little bit of code. It really served as a learning experience as well.

Do with it as you please. I'll probably break things a few times so sorry for that in advance. I also may succumb to my ADHD and abandon it completely at some point too.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(logLevel Level, message any, caller string)

Write writes a new log to the default logger set by the native log package. The output has added color highlighting and the name of the function that called the Write function as well as the line number of the function call.

Types

type Color

type Color string
const (
	Reset  Color = "\033[0m"
	Red    Color = "\033[31m"
	Green  Color = "\033[32m"
	Yellow Color = "\033[33m"
	Blue   Color = "\033[34m"
	Purple Color = "\033[35m"
	Cyan   Color = "\033[36m"
	Grey   Color = "\033[37m"
	White  Color = "\033[97m"
)

type Level

type Level string
const (
	Info    Level = "Info"
	Debug   Level = "Debug"
	Warning Level = "Warning"
	Error   Level = "Error"
	Event   Level = "Event"
)

type Logger added in v0.0.3

type Logger struct {
	Level Level
}

func NewLogger added in v0.0.3

func NewLogger(level Level) *Logger

NewLogger creates a new Logger with the specified log level. The log level is the default level used when calling the Log method. If you want to log a message with a different level, you can use the specific methods for each log level (LogError, LogWarning, LogInfo, LogDebug, LogEvent).

func (*Logger) Log added in v0.0.3

func (l *Logger) Log(message ...any)

Log logs a message with the default log level set for the Logger. If you want to log a message with a different level, you can use the specific methods for each log level (LogError, LogWarning, LogInfo, LogDebug, LogEvent). The default log level can be updated with the SetLevel method.

func (*Logger) LogDebug added in v0.0.3

func (l *Logger) LogDebug(message any)

LogDebug logs a message with the Debug log level.

func (*Logger) LogDebugf added in v0.0.5

func (l *Logger) LogDebugf(format string, args ...any)

func (*Logger) LogError added in v0.0.3

func (l *Logger) LogError(message any)

LogError logs a message with the Error log level.

func (*Logger) LogErrorf added in v0.0.5

func (l *Logger) LogErrorf(format string, args ...any)

func (*Logger) LogEvent added in v0.0.3

func (l *Logger) LogEvent(message any)

LogEvent logs a message with the Event log level. Event logs are meant to be used for important events that occur in the application, such as user actions, system events, or other significant occurrences. Event logs are not meant to be used for debugging or informational purposes, but rather to provide a record of important events that can be used for analysis and troubleshooting.

func (*Logger) LogEventf added in v0.0.5

func (l *Logger) LogEventf(format string, args ...any)

func (*Logger) LogInfo added in v0.0.3

func (l *Logger) LogInfo(message any)

LogInfo logs a message with the Info log level.

func (*Logger) LogInfof added in v0.0.5

func (l *Logger) LogInfof(format string, args ...any)

func (*Logger) LogWarning added in v0.0.3

func (l *Logger) LogWarning(message any)

LogWarning logs a message with the Warning log level.

func (*Logger) LogWarningf added in v0.0.5

func (l *Logger) LogWarningf(format string, args ...any)

func (*Logger) Logf added in v0.0.5

func (l *Logger) Logf(format string, args ...any)

func (*Logger) SetLevel added in v0.0.3

func (l *Logger) SetLevel(level Level)

SetLevel sets the log level for the Logger. This is the default level used when calling the Log method. If you want to log a message with a different level, you can use the specific methods for each log level (LogError, LogWarning, LogInfo, LogDebug, LogEvent).

Jump to

Keyboard shortcuts

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