logger

package
v0.0.0-...-5211220 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2016 License: Apache-2.0 Imports: 4 Imported by: 12

Documentation

Overview

Package logger : The logger package contains the implementation of log handling.

Example (Logger)

This example show the following: - Discard Trace messages - Write Info messages to stdout - Write Warning to stdout and log file - Write Error to stderr and log file

package main

import (
	"io"
	"io/ioutil"
	"log"
	"os"

	logger "github.com/ibm-security-innovation/libsecurity-go/logger"
)

func main() {
	fileName := "log-file.txt"
	os.Remove(fileName)
	file, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		log.Fatalln("Failed to open log file", fileName, ":", err)
	}

	multiW := io.MultiWriter(file, os.Stdout)
	multiE := io.MultiWriter(file, os.Stderr)
	logger.Init(ioutil.Discard, os.Stdout, multiW, multiE)

	logger.Trace.Println("Example: I have something standard to say")
	logger.Info.Println("Example: Special Information")
	logger.Warning.Println("Example: There is something you need to know about")
	logger.Error.Println("Example: Something has failed")
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// Trace : write trace information to the logger
	Trace *log.Logger
	// Info : write info and trace information to the logger
	Info *log.Logger
	// Warning : write warnings, info and trace information to the logger
	Warning *log.Logger
	// Error : write errors, warnings, info and trace information to the logger
	Error *log.Logger
)

Functions

func Init

func Init(traceHandle io.Writer, infoHandle io.Writer, warningHandle io.Writer, errorHandle io.Writer)

Init : initialize the logger

Types

This section is empty.

Jump to

Keyboard shortcuts

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