console_scribeAmqp

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

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

Go to latest
Published: Feb 15, 2015 License: MIT Imports: 3 Imported by: 0

README

console_scribeAmqp

An hook for console.go that send log to an server over AMQP

Created for the Scribe.js log aggregator example


package main

import (
	"fmt"
	K "github.com/guillaumewuip/console.go"
	scribeHook "github.com/guillaumewuip/console_scribeAmqp.go"
)

func main() {

	console := K.NewConsole(K.ColorsOptions{})

    //Create AMQP hook
	h, err := scribeHook.AmqpHook(scribeHook.AmqpOptions{
		"server":       "amqp://localhost",
		"exchange":     "test-notif",
		"exchangeType": "fanout",
		"rountingKey":  "console",
	})

	if err != nil {
		fmt.Println(err)
	} else {
		console.AddHook(h)
	}

	console.Tag("First", "Test").Time().File().Log("This log will be send over %s", "AMQP")
}

Godoc : http://godoc.org/github.com/guillaumewuip/console_scribeAmqp.go

Documentation

Overview

A hook for console.go that send all logs over AMQP (by example to a Scribe.js server)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AmqpHook

func AmqpHook(options AmqpOptions) (func(logger console.Logger) error, error)

Open amqp connection and return an hook that send log to an AMQP queue

Example
myConsole = console.NewConsole(console.ColorsOptions{})

h, err := scribeHook.AmqpHook(scribeHook.AmqpOptions{
	"server":       "amqp://localhost",
	"exchange":     "test-notif",
	"exchangeType": "fanout",
	"rountingKey":  "console",
})

if err != nil {
	fmt.Println(err)
} else {
	myConsole.AddHook(h)
}
Output:

Types

type AmqpOptions

type AmqpOptions map[string]string

Stores amqp options

Example
AmqpOptions{
	"server":       "amqp://localhost",
	"rountingKey":  "config",
	"exchange":     "test-notif",
	"exchangeType": "fanout",
}
Output:

type Location

type Location struct {
	Filename string `json:"filename"`
	Line     int    `json:"line"`
}

Stores filename and file of a log

type Log

type Log struct {
	Type     string   `json:"type"`
	Tags     []string `json:"tags"`
	Location `json:"location"`
	Time     int64  `json:"time"`
	Message  string `json:"message"`
}

A Log will be converted to json

Jump to

Keyboard shortcuts

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