//go:build !windows && !nacl && !plan9
// +build !windows,!nacl,!plan9

package log

import (
	"fmt"
	"log/syslog"
)

var _ Logger = &SyslogLogger{}

// SyslogLogger will be depricated
type SyslogLogger struct {
	w *syslog.Writer
}

// NewSyslogLogger implements Logger
func NewSyslogLogger(w *syslog.Writer) *SyslogLogger {
	return &SyslogLogger{w: w}
}

// Trace log content as Trace
func (s *SyslogLogger) Trace(v ...interface{}) {
	_ = s.w.Trace(fmt.Sprint(v...))
}

// Tracef log content as Trace and format
func (s *SyslogLogger) Tracef(format string, v ...interface{}) {
	_ = s.w.Trace(fmt.Sprintf(format, v...))
}

// Debug log content as Debug
func (s *SyslogLogger) Debug(v ...interface{}) {
	_ = s.w.Debug(fmt.Sprint(v...))
}

// Debugf log content as Debug and format
func (s *SyslogLogger) Debugf(format string, v ...interface{}) {
	_ = s.w.Debug(fmt.Sprintf(format, v...))
}

// Error log content as Error
func (s *SyslogLogger) Error(v ...interface{}) {
	_ = s.w.Err(fmt.Sprint(v...))
}

// Errorf log content as Errorf and format
func (s *SyslogLogger) Errorf(format string, v ...interface{}) {
	_ = s.w.Err(fmt.Sprintf(format, v...))
}

// Info log content as Info
func (s *SyslogLogger) Info(v ...interface{}) {
	_ = s.w.Info(fmt.Sprint(v...))
}

// Infof log content as Infof and format
func (s *SyslogLogger) Infof(format string, v ...interface{}) {
	_ = s.w.Info(fmt.Sprintf(format, v...))
}

// Warn log content as Warn
func (s *SyslogLogger) Warn(v ...interface{}) {
	_ = s.w.Warn(fmt.Sprint(v...))
}

// Warnf log content as Warnf and format
func (s *SyslogLogger) Warnf(format string, v ...interface{}) {
	_ = s.w.Warn(fmt.Sprintf(format, v...))
}

// Fatal log content as Fatal
func (s *SyslogLogger) Fatal(v ...interface{}) {
	_ = s.w.Fatal(fmt.Sprint(v...))
}

// Fatalf log content as Fatalf and format
func (s *SyslogLogger) Fatalf(format string, v ...interface{}) {
	_ = s.w.Fatal(fmt.Sprintf(format, v...))
}

// Level shows log level
func (s *SyslogLogger) Level() LogLevel {
	return LOG_NODEF
}

// SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created
func (s *SyslogLogger) SetLevel(l LogLevel) {}
