1// +build !windows 2 3/* 4** Zabbix 5** Copyright (C) 2001-2021 Zabbix SIA 6** 7** This program is free software; you can redistribute it and/or modify 8** it under the terms of the GNU General Public License as published by 9** the Free Software Foundation; either version 2 of the License, or 10** (at your option) any later version. 11** 12** This program is distributed in the hope that it will be useful, 13** but WITHOUT ANY WARRANTY; without even the implied warranty of 14** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15** GNU General Public License for more details. 16** 17** You should have received a copy of the GNU General Public License 18** along with this program; if not, write to the Free Software 19** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20**/ 21 22package log 23 24import ( 25 "fmt" 26 "log/syslog" 27) 28 29var syslogWriter *syslog.Writer 30 31func createSyslog() (err error) { 32 syslogWriter, err = syslog.New(syslog.LOG_WARNING|syslog.LOG_DAEMON, "zabbix_agent2") 33 return 34} 35 36func procSysLog(format string, args []interface{}, level int) { 37 switch level { 38 case Info: 39 syslogWriter.Info(fmt.Sprintf(format, args...)) 40 case Crit: 41 syslogWriter.Crit(fmt.Sprintf(format, args...)) 42 case Err: 43 syslogWriter.Err(fmt.Sprintf(format, args...)) 44 case Warning: 45 syslogWriter.Warning(fmt.Sprintf(format, args...)) 46 case Debug, Trace: 47 syslogWriter.Debug(fmt.Sprintf(format, args...)) 48 } 49 return 50} 51