log2nsq

package module
v0.0.0-...-00ba5e2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2016 License: GPL-2.0 Imports: 8 Imported by: 4

README

README

Logger 2 NSQ for Golang projects

How does it work?

Simple code example below:

package main

import (
    l2n "github.com/crazyfacka/log2nsq"
)

func main() {
    appname := "sample.logger"
    logger2Nsq := l2n.NewLog2Nsq(&l2n.Options{
		AppName: appname,
	})

    l2n.Printf("Starting application '%s'", appname)

    logger2Nsq.Close()
}
Documentation
PACKAGE DOCUMENTATION

package log2nsq
    import "github.com/crazyfacka/log2nsq"


FUNCTIONS

func Errorf(line string, params ...interface{})
    Errorf outputs data with the grade 'error'.

func Printf(line string, params ...interface{})
    Printf outputs data with the grade 'normal'.

func Println(line string)
    Println is the same as Printf, but without receiving any extra
    arguments.

func Tracef(line string, params ...interface{})
    Tracef outputs data with the grade 'debug'.

TYPES

type Log2Nsq struct {
    // contains filtered or unexported fields
}
    Log2Nsq main struc, representing the logger.

func NewLog2Nsq(opts *Options) *Log2Nsq
    NewLog2Nsq creates a new instance of the logger. It is a mandatory step
    before starting to log any data.

func (l2n *Log2Nsq) Close()
    Close closes all NSQ related comms. Defer it to the end of your
    application.

type Options struct {
    // Application name
    AppName string

    /* NSQ Address
     * If ommited, a default one will be used
     */
    Addr string

    // Additional tags to be included in the final JSON message sent to NSQ
    ExtraTags map[string]string
}
    Options for the Log2Nsq constructor.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(line string, params ...interface{})

Errorf outputs data with the grade 'error'.

func Printf

func Printf(line string, params ...interface{})

Printf outputs data with the grade 'normal'.

func Println

func Println(line string)

Println is the same as Printf, but without receiving any extra arguments.

func Tracef

func Tracef(line string, params ...interface{})

Tracef outputs data with the grade 'debug'.

Types

type Log2Nsq

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

Log2Nsq main struc, representing the logger.

func NewLog2Nsq

func NewLog2Nsq(opts *Options) *Log2Nsq

NewLog2Nsq creates a new instance of the logger. It is a mandatory step before starting to log any data.

func (*Log2Nsq) Close

func (l2n *Log2Nsq) Close()

Close closes all NSQ related comms. Defer it to the end of your application.

type Options

type Options struct {
	// Application name
	AppName string

	/* NSQ Address
	 * If ommited, a default one will be used
	 */
	Addr string

	// Additional tags to be included in the final JSON message sent to NSQ
	ExtraTags map[string]string
}

Options for the Log2Nsq constructor.

Jump to

Keyboard shortcuts

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