glog

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

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 1 Imported by: 0

README

Glog Verbosity Wrapper

This is a wrapper for glog that allows you to set verbosity levels.

The following verbosity levels are supported:

  • 0 - Exit, Fatal, Error, Warning, Info
  • 1 - Exit, Fatal, Error, Warning
  • 2 - Exit, Fatal, Error
  • 3 - Exit, Fatal
  • 4 - Exit
  • 5 - Disable all logging

To set the verbosity level, use the flag.Set function:

flag.Set("v", "0") // Exit, Fatal, Error, Warning, Info
flag.Set("v", "1") // Exit, Fatal, Error, Warning
flag.Set("v", "2") // Exit, Fatal, Error
flag.Set("v", "3") // Exit, Fatal
flag.Set("v", "4") // Exit
flag.Set("v", "5") // Disable all logging

Installation

go get github.com/blankalmasry/glog

Example Usage

package main

import (
    "github.com/blankalmasry/glog"
)

func main() {
    // Required by Glog 
    flag.Parse()
    
    // Set the verbosity level to 1 (Exit, Fatal, Error, Warning) or running the program with the -v flag
    flag.Set("v", "1")

    // Log a message at the "Error" level
    glog.Error("This is an error message")

    // Log a message at the "Warning" level
    glog.Warning("This is a warning message")

    // Log a message at the "Fatal" level
    glog.Fatal("This is a fatal message")

    // This message will not be logged since the verbosity level is set to 1
    glog.Info("This is an info message")
}

Contributing

Feel free to submit a pull request or open an issue.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(args ...interface{})

func Errorf

func Errorf(message string, args ...interface{})

func Errorln

func Errorln(args ...interface{})

func Exit

func Exit(args ...interface{})

func Exitf

func Exitf(message string, args ...interface{})

func Exitln

func Exitln(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(message string, args ...interface{})

func Fatalln

func Fatalln(args ...interface{})

func Flush

func Flush()

func Info

func Info(args ...interface{})

func Infof

func Infof(message string, args ...interface{})

func Infoln

func Infoln(args ...interface{})

func Log

func Log(level LogLevel, args ...interface{})

func Logf

func Logf(level LogLevel, message string, args ...interface{})

func Logln

func Logln(level LogLevel, args ...interface{})

func V

func V(level LogLevel) glog.Verbose

V

  • glog.V() returns true if the log level is greater than or equal to the specified level (i.e. v >= LogLevel).
  • This function returns true if the log level is less than or equal the specified level (i.e. v <= LogLevel).

func Warning

func Warning(args ...interface{})

func Warningf

func Warningf(message string, args ...interface{})

func Warningln

func Warningln(args ...interface{})

Types

type LogLevel

type LogLevel int
const (
	LogLevelInfo LogLevel = iota
	LogLevelWarn
	LogLevelError
	LogLevelFatal
	LogLevelExit
)

type Logger

type Logger interface {
	Log(level LogLevel, message string, args ...interface{})
}

Jump to

Keyboard shortcuts

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