// Copyright (C) 2017 Luke Shumaker // // 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) }