lagregator

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

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

Go to latest
Published: Nov 3, 2016 License: MIT Imports: 4 Imported by: 14

README

LAGREGATOR Build Status

Easy way to merge lagger.Loggers outputs (https://github.com/cloudfoundry/lager)

Relogger

It's a io.Writer that you can pass to another logger and have its log messages redirected to a destination logger:

func ExecuteThat(logger lager.Logger) {
  desinationLogger := logger.Session("execute-that")
  cmd := exec.Command("command-that-outputs-lager-log-messages")
  cmd.Stdout = lagregator.NewRelogger(destinationLogger)
  cmd.Run()
}

All output from command-that-outputs-lager-log-messages that was generated by a lager.Logger will be relogged to destinationLogger on the fly.

RelogStream

It's relogs a given stream:

func ExecuteThat(logger lager.Logger) {
  desinationLogger := logger.Session("execute-that")
  pipeW, pipeR, _ := os.Pipe()

  cmd := exec.Command("command-that-outputs-lager-log-messages")
  cmd.Stdout = pipeW
  cmd.Run()

  lagregator.RelogSream(destinationLogger, pipeR)
}
RelogBytes

It's relogs a given bytes array:

func ExecuteThat(logger lager.Logger) {
  desinationLogger := logger.Session("execute-that")
  cmd := exec.Command("command-that-outputs-lager-log-messages")
  output, _ := cmd.Output()

  lagregator.RelogBytes(destinationLogger, output)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RelogBytes

func RelogBytes(destination lager.Logger, source []byte)

func RelogStream

func RelogStream(destination lager.Logger, input io.Reader)

Types

type Relogger

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

func NewRelogger

func NewRelogger(destination lager.Logger) *Relogger

func (*Relogger) Write

func (r *Relogger) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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