本文整理汇总了Golang中github.com/cihub/seelog.LoggerFromConfigAsFile函数的典型用法代码示例。如果您正苦于以下问题:Golang LoggerFromConfigAsFile函数的具体用法?Golang LoggerFromConfigAsFile怎么用?Golang LoggerFromConfigAsFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoggerFromConfigAsFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
}
开发者ID:houcy,项目名称:push,代码行数:27,代码来源:notify.go
示例2: initAppConfig
func initAppConfig() {
logger, err := seelog.LoggerFromConfigAsFile("./config/log.xml")
if err != nil {
log.Fatalln(err)
}
Logger = logger
}
开发者ID:ZHGDG,项目名称:flute,代码行数:7,代码来源:log.go
示例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()
}
开发者ID:chenyf,项目名称:gibbon,代码行数:33,代码来源:gibbonagent.go
示例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
}
开发者ID:d0ngw,项目名称:go,代码行数:28,代码来源:logger.go
示例5: init
func init() {
logger, err := log.LoggerFromConfigAsFile("seelog.xml")
if err != nil {
panic(err)
}
log.ReplaceLogger(logger)
}
开发者ID:relops,项目名称:gocql-tracing-example,代码行数:7,代码来源:main.go
示例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)
}
开发者ID:idlecloud,项目名称:redishazk,代码行数:8,代码来源:redis_ha.go
示例7: SeelogConfig
func SeelogConfig() seelog.LoggerInterface {
logger, err := seelog.LoggerFromConfigAsFile("seelog_config.xml")
if err != nil {
fmt.Println(err)
return nil
}
return logger
}
开发者ID:adtechtest,项目名称:prog_buy,代码行数:8,代码来源:settings.go
示例8: LoadConf
func LoadConf(configPath string) {
DisableLog()
logger, err := seelog.LoggerFromConfigAsFile(configPath)
if err != nil {
panic(err)
}
UseLogger(logger)
}
开发者ID:ohlinux,项目名称:golang-snippet-cn,代码行数:8,代码来源:logging.go
示例9: InitLogger
func InitLogger(configPath string) {
logger, err := seelog.LoggerFromConfigAsFile(configPath)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
seelog.ReplaceLogger(logger)
}
开发者ID:Everley1993,项目名称:TimerNotificationService,代码行数:8,代码来源:main.go
示例10: loadAppConfig
func loadAppConfig() {
logger, err := seelog.LoggerFromConfigAsFile("./seelog.xml")
if err != nil {
fmt.Println(err)
return
}
UseLogger(logger)
}
开发者ID:jango2015,项目名称:ngw,代码行数:8,代码来源:logs.go
示例11: updateLogger
func updateLogger() error {
logger, err := log.LoggerFromConfigAsFile(LOGGER_CONFIG)
if err != nil {
return err
}
return log.ReplaceLogger(logger)
}
开发者ID:ohhdemgirls,项目名称:trantor,代码行数:8,代码来源:trantor.go
示例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)
}
开发者ID:lucmichalski,项目名称:goiostat,代码行数:58,代码来源:goiostat.go
示例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()
}
开发者ID:houcy,项目名称:push,代码行数:57,代码来源:pushtest.go
示例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}
}
开发者ID:Chandra-TechPassionate,项目名称:Burrow,代码行数:9,代码来源:logger.go
示例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
}
开发者ID:sichuanyl,项目名称:babylon,代码行数:9,代码来源:config.go
示例16: main
func main() {
configFile := flag.String("cfg", "", "The config file")
testSummary := flag.Bool("testSummary", false, "Test summary mode")
flag.Parse()
file, err := os.Open(*configFile)
errHndlr(err, FATAL)
decoder := json.NewDecoder(file)
config := &StartupConfig{}
err = decoder.Decode(&config)
errHndlr(err, FATAL)
if config.RedisInterval == 0 {
config.RedisInterval = defaultRedisInterval
}
logger, err := log.LoggerFromConfigAsFile(config.SeelogConfig)
defer log.Flush()
if err != nil {
panic("error reading " + config.SeelogConfig)
}
fmt.Println("Replacing logger, see log file according to " + config.SeelogConfig)
if *testSummary {
fmt.Println("WARNING: testSummary is on!")
}
log.ReplaceLogger(logger)
runtime.GOMAXPROCS(runtime.NumCPU())
runningConfig, nil := getTmData(config, true)
go houseKeeping(runningConfig, *testSummary)
freeList := NewPool(16, config.RedisString)
<-time.NewTimer(time.Now().Truncate(time.Duration(config.RedisInterval) * time.Second).Add(time.Duration(config.RedisInterval) * time.Second).Sub(time.Now())).C
tickerChan := time.Tick(time.Duration(config.RedisInterval) * time.Second)
for now := range tickerChan {
if now.Second() == 30 {
trc, err := getTmData(config, false)
if err == nil {
runningConfig = trc
}
}
for cdnName, urls := range runningConfig.HealthUrls {
for _, url := range urls {
// log.Info(cdnName, " ", statName, " -> ", url)
if *testSummary {
fmt.Println("Skipping stat write - testSummary mode is ON!")
continue
}
go rascalToRedis(cdnName, url, runningConfig.CacheGroupMap, freeList, config)
}
}
}
}
开发者ID:gitvod,项目名称:traffic_control,代码行数:56,代码来源:rascal_2_redis.go
示例17: loadConfig
func loadConfig() {
// PJ直下で実装した場合
logger, err := log.LoggerFromConfigAsFile("./conf/seelog/development.xml")
if err != nil {
panic("fail to load config")
}
log.ReplaceLogger(logger)
}
开发者ID:shamoto-donuts,项目名称:goSample,代码行数:10,代码来源:main.go
示例18: initializeLogging
func initializeLogging() {
logger, err := log.LoggerFromConfigAsFile("config/logconfig.xml")
if err != nil {
log.Criticalf("An error occurred whilst initializing logging\n", err.Error())
panic(err)
}
log.ReplaceLogger(logger)
}
开发者ID:FireEater64,项目名称:gamq,代码行数:10,代码来源:gamq.go
示例19: initlog
// init log by config
func (s *BaseService) initlog() {
if s.Cfg.Log != "" {
if logger, err := log.LoggerFromConfigAsFile(s.Cfg.Log); err == nil {
log.ReplaceLogger(logger)
}
}
// init echo log
s.echo.SetLogger(NewEchoLogger())
}
开发者ID:xtfly,项目名称:gofd,代码行数:11,代码来源:base.go
示例20: loadLogConfig
func loadLogConfig(configFile string) {
// check for custom logging
if logger, err := log.LoggerFromConfigAsFile(configFile); err != nil {
log.Errorf("[Server] Error loading custom logging config from %s: %v", configFile, err)
} else {
log.ReplaceLogger(logger)
glob.Logger = logger
log.Infof("[Server] Custom logging enabled from %s", configFile)
}
}
开发者ID:armada-io,项目名称:h2,代码行数:10,代码来源:server.go
注:本文中的github.com/cihub/seelog.LoggerFromConfigAsFile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论