1
// Copyright 2012-2014 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
12
"github.com/juju/loggo"
15
type hookLogger struct {
23
func (l *hookLogger) run() {
26
br := bufio.NewReaderSize(l.r, 4096)
28
line, _, err := br.ReadLine()
31
logger.Errorf("cannot read hook output: %v", err)
40
l.logger.Infof("%s", line)
45
func (l *hookLogger) stop() {
46
// We can see the process exit before the logger has processed
47
// all its output, so allow a moment for the data buffered
48
// in the pipe to be processed. We don't wait indefinitely though,
49
// because the hook may have started a background process
50
// that keeps the pipe open.
53
case <-time.After(100 * time.Millisecond):
55
// We can't close the pipe asynchronously, so just
56
// stifle output instead.