Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Latest commit

 

History

History
53 lines (36 loc) · 1.34 KB

README.md

File metadata and controls

53 lines (36 loc) · 1.34 KB

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)
}