console

package module
v0.0.0-...-f476d98 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 6 Imported by: 0

README

Deprecated: please use github.com/ecnepsnai/logtic or something else.


console

A go console implementation

Installation

go get github.com/ecnepsnai/console

Usage

package main

import "github.com/ecnepsnai/console"

func main() {
    Console, err := console.New(logPath, console.LevelDebug)
    if err != nil {
        panic(err.Error())
    }

    Console.Debug("Hopefully this helps")
    Console.Info("Hey, listen!")
    Console.Warn("Uh oh, what did you do?")
    Console.Error("You've ruined EVERYTHING!")
}

Documentation

Overview

Package console provides a simple interface for logging things to stdout & a log file

Index

Constants

View Source
const (
	// LevelDebug debug level includes debugging information and is very verbose
	LevelDebug = 3
	// LevelInfo informational messages for normal operation of the application
	LevelInfo = 2
	// LevelWarn warning messages for potential issues
	LevelWarn = 1
	// LevelError error messages for problems
	LevelError = 0
	// LevelNone no messages
	LevelNone = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path the path to where the log file should live.
	// omit this to disable logging to a file.
	Path string
	// WriteLevel the log level that events must be at least before they
	// are written to the log file.
	WriteLevel int
	// PrintLevel the log level that events must be at least before they
	// are written to console.
	PrintLevel int
}

Config describes the configuration for a console session

type Console

type Console struct {
	// contains filtered or unexported fields
}

Console describes a log object

func New

func New(Config Config) (*Console, error)

New create a new console instance with the provided config.

func (*Console) Close

func (l *Console) Close()

Close close the log file

func (*Console) Debug

func (l *Console) Debug(format string, a ...interface{})

Debug print debug information to the console if verbose logging is enabled Safe to call with sensitive data, but verbose logging should not be enabled on production instances

func (*Console) Error

func (l *Console) Error(format string, a ...interface{})

Error print error information to the console

func (*Console) ErrorDesc

func (l *Console) ErrorDesc(desc string, err error)

ErrorDesc print an error object with description

func (*Console) Fatal

func (l *Console) Fatal(format string, a ...interface{})

Fatal print fatal error and exit the app

func (*Console) Info

func (l *Console) Info(format string, a ...interface{})

Info print informational message to the console

func (*Console) Rotate

func (l *Console) Rotate(destinationDir string) error

Rotate retire the current log file into a gzipped file with todays date

func (*Console) Warn

func (l *Console) Warn(format string, a ...interface{})

Warn print warning information to the console

Jump to

Keyboard shortcuts

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