gomol_loggly

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

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

Go to latest
Published: Aug 16, 2016 License: MIT Imports: 4 Imported by: 0

README

gomol-loggly

GoDoc Build Status Code Coverage

gomol-loggly is a logger for gomol to support sending logs to loggly.

Installation

The recommended way to install is via http://gopkg.in

go get gopkg.in/aphistic/gomol-loggly.v0
...
import "gopkg.in/aphistic/gomol-loggly.v0"

gomol-loggly can also be installed the standard way as well

go get github.com/aphistic/gomol-loggly
...
import "github.com/aphistic/gomol-loggly"

Examples

For brevity a lot of error checking has been omitted, be sure you do your checks!

This is a super basic example of adding a loggly logger to gomol and then logging a few messages:

package main

import (
	"github.com/aphistic/gomol"
	gl "github.com/aphistic/gomol-loggly"
)

func main() {
	// Add a Loggly logger
	logglyCfg := NewLogglyLoggerConfig()
	logglyCfg.Token = "1234"
	logglyLogger, _ := NewLogglyLogger(logglyCfg)
	gomol.AddLogger(logglyLogger)

	// Set some global attrs that will be added to all
	// messages automatically
	gomol.SetAttr("facility", "gomol.example")
	gomol.SetAttr("another_attr", 1234)

	// Initialize the loggers
	gomol.InitLoggers()
	defer gomol.ShutdownLoggers()

	// Log some debug messages with message-level attrs
	// that will be sent only with that message
	for idx := 1; idx <= 10; idx++ {
		gomol.Dbgm(
			gomol.NewAttrs().
				SetAttr("msg_attr1", 4321),
			"Test message %v", idx)
	}
}

Documentation

Overview

Example

Code for the README example to make sure it still builds!

// Add a Loggly logger
logglyCfg := NewLogglyLoggerConfig()
logglyCfg.Token = "1234"
logglyLogger, _ := NewLogglyLogger(logglyCfg)
gomol.AddLogger(logglyLogger)

// Set some global attrs that will be added to all
// messages automatically
gomol.SetAttr("facility", "gomol.example")
gomol.SetAttr("another_attr", 1234)

// Initialize the loggers
gomol.InitLoggers()
defer gomol.ShutdownLoggers()

// Log some debug messages with message-level attrs
// that will be sent only with that message
for idx := 1; idx <= 10; idx++ {
	gomol.Dbgm(
		gomol.NewAttrs().
			SetAttr("msg_attr1", 4321),
		"Test message %v", idx)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogglyLogger

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

func NewLogglyLogger

func NewLogglyLogger(cfg *LogglyLoggerConfig) (*LogglyLogger, error)

func (*LogglyLogger) InitLogger

func (l *LogglyLogger) InitLogger() error

func (*LogglyLogger) IsInitialized

func (l *LogglyLogger) IsInitialized() bool

func (*LogglyLogger) Logm

func (l *LogglyLogger) Logm(timestamp time.Time, level gomol.LogLevel, m map[string]interface{}, msg string) error

func (*LogglyLogger) SetBase

func (l *LogglyLogger) SetBase(base *gomol.Base)

func (*LogglyLogger) ShutdownLogger

func (l *LogglyLogger) ShutdownLogger() error

type LogglyLoggerConfig

type LogglyLoggerConfig struct {
	Token string
}

func NewLogglyLoggerConfig

func NewLogglyLoggerConfig() *LogglyLoggerConfig

Jump to

Keyboard shortcuts

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