Categorygithub.com/aheeva/logger
modulepackage
1.0.6
Repository: https://github.com/aheeva/logger.git
Documentation: pkg.go.dev

# README

logger

Go Reference Go Report Card Issues License Release

A minimalisitic logger module for basic logging, written in Go.

Table of Contents

Example

Client

package main

import (
    "github.com/aheeva/logger"
)

func main() {
    // Initialize logger
    opts := &logger.LoggerOptions{
	LogLevel:    logger.LevelTrace,
	LogFilePath: "logfile.txt",
    }
    close, err := logger.Init(opts)
    if err != nil {
        panic(err)
    }
    defer close()

    logger.Trace("This is just a trace");            // Prints on stdout with a cyan colored text
    logger.Print("This is just a simple log");       // Prints on stdout with a white colored text
    logger.Warn("This is just a warning log");       // Prints on stdout with a yellow colored text
    logger.Success("This is just a success log");    // Prints on stdout with a green colored text
    logger.Error("This is just an error log");       // Prints on stdout with a red colored text
}

Documentation

Logger documentation is hosted at Read the docs.

Development

Logger is still under development. Contributions are always welcome!

Maintainers

License

MIT

# Functions

Error prints logs of type "ERROR".
GetFileSize returns the log file size.
GetLogLevel returns the current log level.
Init initializes a logger.
Print prints logs of type "LOG".
Success prints logs of type "SUCCESS".
Trace prints logs of type "TRACE".
Warn prints logs of type "WARN".

# Constants

Log levels.
Log levels.
Log levels.
Log levels.

# Structs

LoggerOptions to pass to the logger instance.

# Type aliases

LogLevel defines the log level of the logger instance.