clogger

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2015 License: MIT Imports: 5 Imported by: 3

README

clogger

a very basic wrapper around log.Logger and syslog that provides a common interface and severity filtering

Usage

package main

import (
  "github.com/cromega/clogger"
  "os"
)

func main() {
  var logger clogger.Logger
  target := os.Getenv("LOG")

  if target == "local" {
    logger = clogger.CreateIoWriter(os.Stdout)
  } else {
    logger = clogger.CreateSyslog("udp", "logs2.papertrailapp:12345", "app")
  }

  logger.SetLevel(clogger.Debug)
  logger.Info("logging is awesome")
}

Levels are Debug, Info, Warning, Error, Fatal (Critical) and Off.

Documentation

Index

Constants

View Source
const (
	Off = iota
	Fatal
	Error
	Warning
	Info
	Debug
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warning(format string, args ...interface{})
	Error(format string, args ...interface{})
	Fatal(format string, args ...interface{})
	SetLevel(level int)
	Close()
}

func CreateIoWriter

func CreateIoWriter(target io.Writer) Logger

func CreateSyslog

func CreateSyslog(proto, raddr, prefix string) (Logger, error)

Jump to

Keyboard shortcuts

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