本文整理匯總了Golang中github.com/juju/juju/utils/syslog.SyslogConfig類的典型用法代碼示例。如果您正苦於以下問題:Golang SyslogConfig類的具體用法?Golang SyslogConfig怎麽用?Golang SyslogConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SyslogConfig類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: assertRsyslogConfigContents
func (s *syslogConfigSuite) assertRsyslogConfigContents(c *gc.C, slConfig *syslog.SyslogConfig, expectedConf string) {
data, err := slConfig.Render()
c.Assert(err, jc.ErrorIsNil)
if len(data) == 0 {
c.Fatal("got empty data from render")
}
d := string(data)
if d != expectedConf {
diff(c, d, expectedConf)
c.Fail()
}
}
示例2: newRsyslogConfigHandler
func newRsyslogConfigHandler(st *apirsyslog.State, mode RsyslogMode, tag, namespace string, stateServerAddrs []string) (*RsyslogConfigHandler, error) {
var syslogConfig *syslog.SyslogConfig
if mode == RsyslogModeAccumulate {
syslogConfig = syslog.NewAccumulateConfig(
tag, logDir, 0, namespace, stateServerAddrs,
)
} else {
syslogConfig = syslog.NewForwardConfig(
tag, logDir, 0, namespace, stateServerAddrs,
)
}
// Historically only machine-0 includes the namespace in the log
// dir/file; for backwards compatibility we continue the tradition.
if tag != "machine-0" {
namespace = ""
}
kind, err := names.TagKind(tag)
if err != nil {
return nil, err
}
if kind == names.MachineTagKind {
if namespace == "" {
syslogConfig.ConfigFileName = "25-juju.conf"
} else {
syslogConfig.ConfigFileName = fmt.Sprintf("25-juju-%s.conf", namespace)
}
} else {
syslogConfig.ConfigFileName = fmt.Sprintf("26-juju-%s.conf", tag)
}
syslogConfig.ConfigDir = rsyslogConfDir
syslogConfig.LogDir = logDir
if namespace != "" {
syslogConfig.LogDir += "-" + namespace
}
return &RsyslogConfigHandler{
st: st,
mode: mode,
syslogConfig: syslogConfig,
tag: tag,
}, nil
}
示例3: newRsyslogConfigHandler
func newRsyslogConfigHandler(st *apirsyslog.State, mode RsyslogMode, tag names.Tag, namespace string, stateServerAddrs []string) (*RsyslogConfigHandler, error) {
var syslogConfig *syslog.SyslogConfig
if mode == RsyslogModeAccumulate {
syslogConfig = syslog.NewAccumulateConfig(tag.String(), logDir, 0, namespace, stateServerAddrs)
} else {
syslogConfig = syslog.NewForwardConfig(tag.String(), logDir, 0, namespace, stateServerAddrs)
}
// Historically only machine-0 includes the namespace in the log
// dir/file; for backwards compatibility we continue the tradition.
if tag != names.NewMachineTag("0") {
namespace = ""
}
switch tag := tag.(type) {
case names.MachineTag:
if namespace == "" {
syslogConfig.ConfigFileName = "25-juju.conf"
} else {
syslogConfig.ConfigFileName = fmt.Sprintf("25-juju-%s.conf", namespace)
}
default:
syslogConfig.ConfigFileName = fmt.Sprintf("26-juju-%s.conf", tag)
}
syslogConfig.ConfigDir = rsyslogConfDir
syslogConfig.LogDir = logDir
if namespace != "" {
syslogConfig.LogDir += "-" + namespace
}
return &RsyslogConfigHandler{
st: st,
mode: mode,
syslogConfig: syslogConfig,
tag: tag,
}, nil
}
示例4: assertRsyslogConfigPath
func (s *syslogConfigSuite) assertRsyslogConfigPath(c *gc.C, slConfig *syslog.SyslogConfig) {
slConfig.ConfigDir = s.configDir
slConfig.ConfigFileName = "rsyslog.conf"
c.Assert(slConfig.ConfigFilePath(), gc.Equals, filepath.Join(s.configDir, "rsyslog.conf"))
}
示例5: assertRsyslogConfigContents
func (s *syslogConfigSuite) assertRsyslogConfigContents(c *gc.C, slConfig *syslog.SyslogConfig,
expectedConf string) {
data, err := slConfig.Render()
c.Assert(err, gc.IsNil)
c.Assert(string(data), gc.Equals, expectedConf)
}