本文整理匯總了Golang中github.com/cihub/seelog.LoggerFromConfigAsFile函數的典型用法代碼示例。如果您正苦於以下問題:Golang LoggerFromConfigAsFile函數的具體用法?Golang LoggerFromConfigAsFile怎麽用?Golang LoggerFromConfigAsFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了LoggerFromConfigAsFile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
logConfigFile := flag.String("l", "./conf/log.xml", "Log config file")
configFile := flag.String("c", "./conf/conf.json", "Config file")
flag.Parse()
logger, err := log.LoggerFromConfigAsFile(*logConfigFile)
if err != nil {
fmt.Printf("Load log config failed: (%s)\n", err)
os.Exit(1)
}
log.ReplaceLogger(logger)
err = conf.LoadConfig(*configFile)
if err != nil {
log.Warnf("LoadConfig (%s) failed: (%s)\n", *configFile, err)
os.Exit(1)
}
http.HandleFunc("/api/v1/notify", postNotify)
err = http.ListenAndServe(conf.Config.Notify.Addr, nil)
if err != nil {
log.Warnf("failed to ListenAndServe: ", err)
os.Exit(1)
}
}
示例2: initAppConfig
func initAppConfig() {
logger, err := seelog.LoggerFromConfigAsFile("./config/log.xml")
if err != nil {
log.Fatalln(err)
}
Logger = logger
}
示例3: main
func main() {
//err := LoadConfig("/system/etc/conf.json")
err := LoadConfig("./conf.json")
if err != nil {
fmt.Printf("LoadConfig failed: (%s)", err)
os.Exit(1)
}
//logger, err := log.LoggerFromConfigAsFile("/system/etc/log.xml")
logger, err := log.LoggerFromConfigAsFile("./log.xml")
if err != nil {
fmt.Printf("Load log config failed: (%s)\n", err)
os.Exit(1)
}
log.ReplaceLogger(logger)
//wg := &sync.WaitGroup{}
agent := NewAgent()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
agent.Run()
log.Infof("agent quited")
wg.Done()
}()
sig := <-c
log.Infof("Received signal '%v', exiting\n", sig)
agent.Stop()
wg.Wait()
}
示例4: InitLogger
func InitLogger(configFile string) {
fmt.Fprintln(os.Stderr, "Use "+configFile+" init Logger")
m.Lock()
defer m.Unlock()
if loggerInitd {
Errorf("Logger has been already inited.")
return
}
seelogger, err := seelog.LoggerFromConfigAsFile(configFile)
if err != nil {
log.Panicf("Can't init Logger,error:%s", err)
return
} else {
//確保取得正確的調用堆棧
seelogger.SetAdditionalStackDepth(2)
}
realLogger := logger.(*SeeLogLogger)
if realLogger.seelogger != nil {
realLogger.seelogger.Flush()
realLogger.seelogger.Close()
}
realLogger.seelogger = seelogger
loggerInitd = true
}
示例5: init
func init() {
logger, err := log.LoggerFromConfigAsFile("seelog.xml")
if err != nil {
panic(err)
}
log.ReplaceLogger(logger)
}
示例6: InitSeeLog
func InitSeeLog(seeLogCfgFile string) {
logger, err := log.LoggerFromConfigAsFile(seeLogCfgFile)
if err != nil {
log.Errorf("Parse seelog config file error: %s", err.Error)
os.Exit(1)
}
log.ReplaceLogger(logger)
}
示例7: SeelogConfig
func SeelogConfig() seelog.LoggerInterface {
logger, err := seelog.LoggerFromConfigAsFile("seelog_config.xml")
if err != nil {
fmt.Println(err)
return nil
}
return logger
}
示例8: LoadConf
func LoadConf(configPath string) {
DisableLog()
logger, err := seelog.LoggerFromConfigAsFile(configPath)
if err != nil {
panic(err)
}
UseLogger(logger)
}
示例9: InitLogger
func InitLogger(configPath string) {
logger, err := seelog.LoggerFromConfigAsFile(configPath)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
seelog.ReplaceLogger(logger)
}
示例10: loadAppConfig
func loadAppConfig() {
logger, err := seelog.LoggerFromConfigAsFile("./seelog.xml")
if err != nil {
fmt.Println(err)
return
}
UseLogger(logger)
}
示例11: updateLogger
func updateLogger() error {
logger, err := log.LoggerFromConfigAsFile(LOGGER_CONFIG)
if err != nil {
return err
}
return log.ReplaceLogger(logger)
}
示例12: main
func main() {
defer log.Flush()
logger, err := log.LoggerFromConfigAsFile("seelog.xml")
if nil != err {
log.Warn("Failed to load config", err)
}
log.ReplaceLogger(logger)
flag.Parse()
statsTransformChannel := make(chan *diskStat.DiskStat, 10)
statsOutputChannel := make(chan *diskStat.ExtendedIoStats, 10)
var output outputInterface.Output
proto := PStdOut
switch *protocolType {
case "protobuffers":
{
proto = PProtoBuffers
}
case "json":
{
proto = PJson
}
default:
{
if *outputType == "zmq" {
proto = PProtoBuffers
} else if *outputType == "stdout" {
proto = PStdOut
}
}
}
switch *outputType {
case "zmq":
output, err = zmqOutput.NewZmqOutput(queueUrl, proto)
case "nano":
output, err = nanoMsgOutput.NewNanoMsgOutput(queueUrl, proto)
default:
output = &logOutput.LogOutput{proto}
}
if nil != err {
log.Error("Failed to setup output ", err)
}
go ioStatTransform.TransformStat(statsTransformChannel, statsOutputChannel)
go statsOutput.Output(statsOutputChannel, output)
for {
readAndSendStats(statsTransformChannel)
time.Sleep(time.Second * time.Duration(*interval))
}
close(statsTransformChannel)
close(statsOutputChannel)
}
示例13: main
func main() {
cfgfile := "conf.json"
begin := 0
count := 1
if len(os.Args) >= 3 {
begin, _ = strconv.Atoi(os.Args[1])
count, _ = strconv.Atoi(os.Args[2])
}
r, err := os.Open(cfgfile)
if err != nil {
fmt.Printf("failed to open config file %s", cfgfile)
os.Exit(1)
}
var config Config
decoder := json.NewDecoder(r)
err = decoder.Decode(&config)
if err != nil {
fmt.Printf("invalid config file")
os.Exit(1)
}
if config.ReadTimeout <= 0 {
config.ReadTimeout = time.Duration(20)
}
logger, err := log.LoggerFromConfigAsFile("log.xml")
if err != nil {
fmt.Printf("Load log config failed: (%s)\n", err)
os.Exit(1)
}
log.ReplaceLogger(logger)
server, _ := net.ResolveTCPAddr("tcp4", config.Server)
wg := &sync.WaitGroup{}
c := make(chan os.Signal, 1)
ctrl := make(chan bool, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
running := true
wg.Add(1)
go func() {
sig := <-c
log.Infof("Received signal '%v', exiting\n", sig)
running = false
close(ctrl)
wg.Done()
}()
for n := begin; n < begin+count; n++ {
if !running {
break
}
go runClient(n, &config, wg, ctrl, nil, server)
time.Sleep(config.Interval * time.Millisecond)
}
wg.Wait()
}
示例14: NewLogger
func NewLogger(cfgfile string) *BurrowLogger {
logger, err := log.LoggerFromConfigAsFile(cfgfile)
if err != nil {
log.Criticalf("Cannot start logger: %v", err)
os.Exit(1)
}
log.ReplaceLogger(logger)
return &BurrowLogger{logger}
}
示例15: log_init
func log_init() {
defer log.Flush()
logger, e := log.LoggerFromConfigAsFile(GetConfigDir() + "/log.conf")
if e != nil {
log.Criticalf("Error %v", e)
}
log.ReplaceLogger(logger)
//TODO timer watch config file
}