tracelog

package module
Version: v0.0.0-...-c71e233 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2018 License: BSD-2-Clause-Views Imports: 13 Imported by: 178

README

Tracelog

Tracelog sits on top of Go's log library. See the following example for an implementation (it's super easy to use)

Example
package main

import (
    "fmt"
    "errors"
    "github.com/goinggo/tracelog"
)

func main() {
    //tracelog.StartFile(tracelog.LevelTrace, "/Users/bill/Temp/logs", 1)
    
    tracelog.Start(tracelog.LevelTrace)
    tracelog.Trace("main", "main", "Hello Trace")
    tracelog.Info("main", "main", "Hello Info")
    tracelog.Warning("main", "main", "Hello Warn")
    tracelog.Errorf(fmt.Errorf("Exception At..."), "main", "main", "Hello Error")
    
    Example()
    tracelog.Stop()
}

func foo() error {
        return errors.New("test")
}

func Example() {
    tracelog.Started("main", "Example")
    
    if err := foo(); err != nil {
        tracelog.CompletedError(err, "main", "Example")
        return
    }
    
    tracelog.Completed("main", "Example")
}
Output
TRACE: 2013/11/07 08:24:32 main.go:12: main : main : Info : Hello Trace
INFO: 2013/11/07 08:24:32 main.go:13: main : main : Info : Hello Info
WARNING: 2013/11/07 08:24:32 main.go:14: main : main : Info : Hello Warn
ERROR: 2013/11/07 08:24:32 main.go:15: main : main : Info : Hello Error : Exception At...
TRACE: 2013/11/07 08:24:32 main.go:23: main : Example : Started
TRACE: 2013/11/07 08:24:32 main.go:31: main : Example : Completed
TRACE: 2013/11/07 08:24:32 tracelog.go:149: main : Stop : Started
TRACE: 2013/11/07 08:24:32 tracelog.go:156: main : Stop : Completed

For more details on how to use this package (or to see how it works), see the source. Also, docs

Copyright 2013 Ardan Studios. All rights reserved.
Use of this source code is governed by a BSD-style license that can be found in the LICENSE handle.

Package TraceLog implements a logging system to trace all aspect of your code. This is great for task oriented programs. Based on the Go log standard library. It provides 4 destinations with logging levels plus you can attach a file for persistent writes. A log clean process is provided to maintain disk space. There is also email support to send email alerts.

Ardan Studios
12973 SW 112 ST, Suite 153
Miami, FL 33186
bill@ardanstudios.com

Click To View Documentation

Documentation

Overview

Package tracelog : logcalls.go provides formatting functions.

Package tracelog : logcalls.go provides formatting functions.

Package tracelog implements a logging system to trace all aspect of your code. This is great for task oriented programs. Based on the Go log standard library. It provides 4 destinations with logging levels plus you can attach a file for persistent writes. A log clean process is provided to maintain disk space. There is also email support to send email alerts.

Index

Constants

View Source
const (
	// LevelTrace logs everything
	LevelTrace int32 = 1

	// LevelInfo logs Info, Warnings and Errors
	LevelInfo int32 = 2

	// LevelWarn logs Warning and Errors
	LevelWarn int32 = 4

	// LevelError logs just Errors
	LevelError int32 = 8
)

Variables

This section is empty.

Functions

func Alert

func Alert(subject string, title string, functionName string, format string, a ...interface{})

Alert write to the Error destination and sends email alert

func Alertcd

func Alertcd(callDepth int, subject string, title string, functionName string, format string, a ...interface{})

Alertcd write to the Error destination and sends email alert

func Completed

func Completed(title string, functionName string)

Completed uses the Serialize destination and writes a Completed tag to the log line

func CompletedAlert

func CompletedAlert(subject string, title string, functionName string, format string, a ...interface{})

CompletedAlert write to the Error destination, writes a Completed tag to the log line and sends email alert

func CompletedAlertcd

func CompletedAlertcd(callDepth int, subject string, title string, functionName string, format string, a ...interface{})

CompletedAlertcd write to the Error destination, writes a Completed tag to the log line and sends email alert

func CompletedError

func CompletedError(err error, title string, functionName string)

CompletedError uses the Error destination and writes a Completed tag to the log line

func CompletedErrorcd

func CompletedErrorcd(callDepth int, err error, title string, functionName string)

CompletedErrorcd uses the Error destination and writes a Completed tag to the log line

func CompletedErrorf

func CompletedErrorf(err error, title string, functionName string, format string, a ...interface{})

CompletedErrorf uses the Error destination and writes a Completed tag to the log line

func CompletedErrorfcd

func CompletedErrorfcd(callDepth int, err error, title string, functionName string, format string, a ...interface{})

CompletedErrorfcd uses the Error destination and writes a Completed tag to the log line

func Completedcd

func Completedcd(callDepth int, title string, functionName string)

Completedcd uses the Trace destination and writes a Completed tag to the log line

func Completedf

func Completedf(title string, functionName string, format string, a ...interface{})

Completedf uses the Serialize destination and writes a Completed tag to the log line

func Completedfcd

func Completedfcd(callDepth int, title string, functionName string, format string, a ...interface{})

Completedfcd uses the Trace destination and writes a Completed tag to the log line

func ConfigureEmail

func ConfigureEmail(host string, port int, userName string, password string, to []string)

ConfigureEmail configures the email system for use.

func Error

func Error(err error, title string, functionName string)

Error writes to the Error destination and accepts an err

func Errorcd

func Errorcd(callDepth int, err error, title string, functionName string)

Errorcd writes to the Error destination and accepts an err

func Errorf

func Errorf(err error, title string, functionName string, format string, a ...interface{})

Errorf writes to the Error destination and accepts an err

func Errorfcd

func Errorfcd(callDepth int, err error, title string, functionName string, format string, a ...interface{})

Errorfcd writes to the Error destination and accepts an err

func Info

func Info(title string, functionName string, format string, a ...interface{})

Info writes to the Info destination

func Infocd

func Infocd(callDepth int, title string, functionName string, format string, a ...interface{})

Infocd writes to the Info destination

func LogLevel

func LogLevel() int32

LogLevel returns the configured logging level.

func SendEmailException

func SendEmailException(subject string, message string, a ...interface{}) error

SendEmailException will send an email along with the exception.

func Start

func Start(logLevel int32)

Start initializes tracelog and only displays the specified logging level.

func StartFile

func StartFile(logLevel int32, baseFilePath string, daysToKeep int)

StartFile initializes tracelog and only displays the specified logging level and creates a file to capture writes.

func Started

func Started(title string, functionName string)

Started uses the Serialize destination and adds a Started tag to the log line

func Startedcd

func Startedcd(callDepth int, title string, functionName string)

Startedcd uses the Trace destination and adds a Started tag to the log line

func Startedf

func Startedf(title string, functionName string, format string, a ...interface{})

Startedf uses the Serialize destination and writes a Started tag to the log line

func Startedfcd

func Startedfcd(callDepth int, title string, functionName string, format string, a ...interface{})

Startedfcd uses the Trace destination and writes a Started tag to the log line

func Stop

func Stop() error

Stop will release resources and shutdown all processing.

func Trace

func Trace(title string, functionName string, format string, a ...interface{})

Trace writes to the Trace destination

func Tracecd

func Tracecd(callDepth int, title string, functionName string, format string, a ...interface{})

Tracecd writes to the Trace destination

func Warning

func Warning(title string, functionName string, format string, a ...interface{})

Warning writes to the Warning destination

func Warningcd

func Warningcd(callDepth int, title string, functionName string, format string, a ...interface{})

Warningcd writes to the Warning destination

Types

This section is empty.

Jump to

Keyboard shortcuts

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