summaryrefslogtreecommitdiff
path: root/nslcd_systemd/log.go
blob: 8a646f8b963bcc3871d495566174c367376fd528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2017 Luke Shumaker <lukeshu@sbcglobal.net>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA

package nslcd_systemd

import (
	"io"

	"git.lukeshu.com/go/libnslcd/nslcd_server"
)

type PrefixLogger struct {
	Prefix string
	Logger nslcd_server.Logger
}

func (pl PrefixLogger) Emerg(m string) error   { return pl.Logger.Emerg(pl.Prefix + m) }
func (pl PrefixLogger) Alert(m string) error   { return pl.Logger.Alert(pl.Prefix + m) }
func (pl PrefixLogger) Crit(m string) error    { return pl.Logger.Crit(pl.Prefix + m) }
func (pl PrefixLogger) Err(m string) error     { return pl.Logger.Err(pl.Prefix + m) }
func (pl PrefixLogger) Warning(m string) error { return pl.Logger.Warning(pl.Prefix + m) }
func (pl PrefixLogger) Notice(m string) error  { return pl.Logger.Notice(pl.Prefix + m) }
func (pl PrefixLogger) Info(m string) error    { return pl.Logger.Info(pl.Prefix + m) }
func (pl PrefixLogger) Debug(m string) error   { return pl.Logger.Debug(pl.Prefix + m) }

func (pl PrefixLogger) Write(m []byte) (int, error) {
	return pl.Logger.Write(append([]byte(pl.Prefix), m...))
}
func (pl PrefixLogger) WriteString(m string) (int, error) {
	return io.WriteString(pl.Logger, pl.Prefix+m)
}