1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/logger/journald/journald.go
Dan Walsh 364287b741 Add journald as a supported logger for containers
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2015-04-21 12:57:54 -04:00

35 lines
712 B
Go

package journald
import (
"fmt"
"github.com/coreos/go-systemd/journal"
"github.com/docker/docker/daemon/logger"
)
type Journald struct {
Jmap map[string]string
}
func New(id string) (logger.Logger, error) {
if !journal.Enabled() {
return nil, fmt.Errorf("journald is not enabled on this host")
}
jmap := map[string]string{"MESSAGE_ID": id}
return &Journald{Jmap: jmap}, nil
}
func (s *Journald) Log(msg *logger.Message) error {
if msg.Source == "stderr" {
return journal.Send(string(msg.Line), journal.PriErr, s.Jmap)
}
return journal.Send(string(msg.Line), journal.PriInfo, s.Jmap)
}
func (s *Journald) Close() error {
return nil
}
func (s *Journald) Name() string {
return "Journald"
}