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

cloudfoundry/lager helpers for relogging command output

License

Notifications You must be signed in to change notification settings

tscolari/lagregator

Repository files navigation

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

About

cloudfoundry/lager helpers for relogging command output

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published