本文整理匯總了Golang中code/google/com/p/log4go.LoadConfiguration函數的典型用法代碼示例。如果您正苦於以下問題:Golang LoadConfiguration函數的具體用法?Golang LoadConfiguration怎麽用?Golang LoadConfiguration使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了LoadConfiguration函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
l4g.LoadConfiguration("log4g.xml")
ivr.InitIVRServer(8084)
// ivr.InitDB("tcp(172.168.2.107:3306)", "root", "root01", "ivr")
}
示例2: main
func main() {
flag.Parse()
if err := InitConfig(); err != nil {
panic(err)
}
runtime.GOMAXPROCS(Conf.MaxProc)
log.LoadConfiguration(Conf.Log)
defer log.Close()
log.Info("logic[%s] start", Ver)
perf.Init(Conf.PprofAddrs)
// router rpc
if err := InitRouter(); err != nil {
log.Warn("router rpc current can't connect, retry")
}
MergeRoomCount()
go SyncRoomCount()
// logic rpc
if err := InitRPC(NewDefaultAuther()); err != nil {
panic(err)
}
if err := InitKafka(Conf.KafkaAddrs); err != nil {
panic(err)
}
if err := InitHTTP(); err != nil {
panic(err)
}
// block until a signal is received.
InitSignal()
}
示例3: Configure
// Configure the Application
func (a *Application) Configure() error {
log.Debug("Reading logging config file")
log.LoadConfiguration("./loggers.xml")
log.Debug("Reading application config file")
file, err := ioutil.ReadFile("./config.json")
if err != nil {
log.Error("Error opening config file: ", err)
panic(err)
}
log.Info("Config Loaded:\n\n" + string(file))
var config Config
err = json.Unmarshal(file, &config)
if err != nil {
log.Error("Error parsing config file: ", err)
panic(err)
}
debug, ok := config["debug"].(bool)
if !ok {
debug = false
}
a.Config = config
a.Debug = debug
return nil
}
示例4: main
func main() {
var err error
// Parse cmd-line arguments
flag.Parse()
log.Info("web ver: \"%s\" start", ver.Version)
if err = InitConfig(); err != nil {
panic(err)
}
// Set max routine
runtime.GOMAXPROCS(Conf.MaxProc)
// init log
log.LoadConfiguration(Conf.Log)
defer log.Close()
// init zookeeper
zkConn, err := InitZK()
if err != nil {
if zkConn != nil {
zkConn.Close()
}
panic(err)
}
// start pprof http
perf.Init(Conf.PprofBind)
// start http listen.
StartHTTP()
// process init
if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
panic(err)
}
// init signals, block wait signals
signalCH := InitSignal()
HandleSignal(signalCH)
log.Info("web stop")
}
示例5: TestWebManager
func TestWebManager(t *testing.T) {
l4g.LoadConfiguration("../../config/logConfig.xml")
configFile, readConfigFileErr := os.Open("../../config/overwall.config")
if readConfigFileErr != nil {
t.Fatal(readConfigFileErr)
}
decoder := json.NewDecoder(configFile)
config := &Config{}
decoder.Decode(&config)
fmt.Printf("config info:\n%+v\n", config)
opt := news.Option{}
opt.SpeechFileDir = config.SpeechFileDir
opt.SpeechCache = config.CacheSize
opt.SentenceLen = config.OneSentenceLen
opt.MaxGenVoiceTask = config.MaxGenVoiceTask
opt.EasyreadUsername = config.EasyreadUsername
opt.EasyreadPwd = config.EasyreadPwd
opt.GenVoiceFile = true
fmt.Printf("opt info:\n%+v\n", opt)
newsManager := news.NewNewsManager(opt)
webManager := NewWebManager(newsManager, "8787", "/home/noah/workspace/OverWall/config/chimes1.mp3")
webManager.StartServer()
}
示例6: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
//l4g.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter("server.log", false))
// creates a tcp listener
l4g.LoadConfiguration("./conf/log4go.xml")
tcpAddr, err := net.ResolveTCPAddr("tcp4", ":8989")
checkError(err)
listener, err := net.ListenTCP("tcp", tcpAddr)
checkError(err)
defer l4g.Close()
// creates a server
config := &gotcp.Config{
PacketSendChanLimit: 20,
PacketReceiveChanLimit: 20,
}
srv := gotcp.NewServer(config, &Callback{}, &echo.EchoProtocol{})
// starts service
go srv.Start(listener, time.Second)
l4g.Debug("listening: %s", listener.Addr())
//log.Println("listening:", listener.Addr())
// catchs system signal
chSig := make(chan os.Signal)
signal.Notify(chSig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR2) //, syscall.SIGINT, syscall.SIGTERM
l4g.Trace("Signal: %s", <-chSig)
//log.Println("Signal: ", <-chSig)
// stops service
srv.Stop()
}
示例7: main
func main() {
var (
addr *net.UDPAddr
listener *net.UDPConn
err error
)
log.LoadConfiguration(Conf.Log)
defer log.Close()
if addr, err = net.ResolveUDPAddr("udp4", Conf.Bind); err != nil {
log.Error("net.ResolveUDPAddr(\"udp4\", \"%s\") error(%v)", Conf.Bind, err)
return
}
if listener, err = net.ListenUDP("udp4", addr); err != nil {
log.Error("net.ListenUDP(\"udp4\", \"%v\") error(%v)", addr, err)
return
}
defer listener.Close()
if Debug {
log.Debug("start udp listen: \"%s\"", Conf.Bind)
}
//N core accept
for i := 0; i < Conf.MaxProc; i++ {
go acceptUDP(listener)
}
//wait
InitSignal()
}
示例8: loadLog4goConfig
func loadLog4goConfig() {
log4go.Debug("Loading configuration")
_, err := os.Stat(logname)
if os.IsNotExist(err) {
return
}
log4go.LoadConfiguration(logname)
}
示例9: NoTestQueryLogisticsInfo
func NoTestQueryLogisticsInfo(t *testing.T) {
l4g.LoadConfiguration("../config/logConfig.xml")
logisticsInfo, err := Query("shentong", "668031148649")
if err != nil {
t.Fatal(err)
}
t.Log(logisticsInfo)
}
示例10: main
func main() {
l4g.LoadConfiguration("./conf/log4go.xml")
if beego.RunMode == "dev" {
beego.DirectoryIndex = true
beego.StaticDir["/swagger"] = "swagger"
}
beego.Run()
}
示例11: main
func main() {
// Load the configuration (isn't this easy?)
l4g.LoadConfiguration("example.xml")
// And now we're ready!
l4g.Finest("This will only go to those of you really cool UDP kids! If you change enabled=true.")
l4g.Debug("Oh no! %d + %d = %d!", 2, 2, 2+2)
l4g.Info("About that time, eh chaps?")
}
示例12: main
func main() {
var err error
flag.Parse()
log.LoadConfiguration("logging.xml")
// Load configuration
alfConfig, err := config.NewConfig(*configPath)
if err != nil {
log.Error("Error parsing configuration: ", err.Error())
os.Exit(1)
}
// Connect to the database
alfDb := db.NewDB()
err = alfDb.Connect(alfConfig.DbUrl)
defer alfDb.Close()
if err != nil {
log.Error("Error connecting to DB: ", err.Error())
os.Exit(1)
}
// Get all hosts, and all checks
var hosts []db.Host
err = alfDb.Hosts.FindAll(&hosts)
if err != nil {
log.Error("Failed to get hosts: ", err.Error())
os.Exit(1)
}
log.Debug("Hosts: %v", hosts)
var tasks []db.Task
err = alfDb.Tasks.FindAll(&tasks)
if err != nil {
log.Error("Failed to get tasks: ", err.Error())
os.Exit(1)
}
log.Debug("tasks: %v", tasks)
// Run every task on every host
for _, host := range hosts {
for _, task := range tasks {
runner := NewRunner(&host, &task, alfDb)
// Launch runner in its own goroutine
go runner.run()
}
}
// Run HTTP API handlers
httpService := http.NewHttpService(alfConfig.BindAddress, alfDb)
go httpService.Start()
// Block forever, exit with a SIGINT
select {}
}
示例13: main
func main() {
// init cmd args
flag.Parse()
// init config
if err := initConfig(); err != nil {
os.Exit(termExit)
}
// init log
log.LoadConfiguration(conf.Log)
defer log.Close()
if len(conf.Sentinel) == 0 {
// set to zk
log.Error("conf.Sentinel don't have any sentinel addr")
time.Sleep(logWait)
os.Exit(retryExit)
}
log.Info("sentinels: \"%v\", master: \"%s\"", conf.Sentinel, conf.Master)
// init sentinel addrs
for _, addr := range conf.Sentinel {
sentinelList.PushBack(addr)
}
redisConn := sentinel()
if redisConn == nil {
log.Error("sentinel can't connect")
time.Sleep(logWait)
os.Exit(retryExit)
}
defer redisConn.Close()
// master redis
redisMaster := masterAddr(redisConn)
log.Debug("redis master: \"%s\"", redisMaster)
isMaster := checkRole(redisMaster, roleMaster)
if isMaster {
refreshSentinel(redisConn)
} else {
log.Warn("abort the mission, master not ok")
time.Sleep(logWait)
os.Exit(retryExit)
}
// set to zk
zkConn := zkDial()
if zkConn == nil {
log.Error("zookeeper can't connect")
time.Sleep(logWait)
os.Exit(retryExit)
}
defer zkConn.Close()
if err := zkData(zkConn, redisMaster); err != nil {
log.Error("zookeeper set data failed")
time.Sleep(logWait)
os.Exit(retryExit)
}
time.Sleep(logWait)
os.Exit(okExit)
}
示例14: main
// 爬蟲主程序
func main() {
// l4g的配置文件
l4g.LoadConfiguration(SPIDER_LOGCONF_XML)
// refer : http://www.01happy.com/golang-command-line-arguments/
var confPath string
var logPath string
var printVer bool
flag.StringVar(&confPath, "c", "../../conf", "config file path")
flag.StringVar(&logPath, "l", "../../log", "log file path")
flag.BoolVar(&printVer, "v", false, "print version")
flag.Parse()
if printVer {
utils.PrintVersion()
os.Exit(0)
}
l4g.Info("Hi, dash's %s is running...\n", "go_mini_spider")
confFile := confPath + "/" + SPIDER_CONFIG_FILE
conf, err := conf.InitConf(confFile)
if err != nil {
l4g.Error("read spider config failed, err [%s]", err)
SlowExit()
}
var seedUrls []string
// read and parse json,相對路徑
b, err := ioutil.ReadFile(confPath + "/" + conf.UrlListFile)
if err != nil {
l4g.Error("readfile err[%s]", err)
SlowExit()
}
//json to []string
if err := json.Unmarshal(b, &seedUrls); err != nil {
l4g.Error("parse json err[%s]", err)
SlowExit()
}
//GOMAXPROCS設置
runtime.GOMAXPROCS(runtime.NumCPU())
// 啟動爬蟲
spider := spider.NewSpider(seedUrls, conf, confPath)
spider.Start()
// 等待任務完成
spider.Wait()
time.Sleep(1 * time.Second)
}
示例15: NoTestUpdateAndGetChangedLogistics
func NoTestUpdateAndGetChangedLogistics(t *testing.T) {
l4g.LoadConfiguration("../config/logConfig.xml")
service, err := NewLogisticsService("../../db/pilogistics.db")
if err != nil {
t.Fatal(err)
}
logisticsCh := make(chan *ChangedLogisticsInfo, 1)
go service.UpdateAndGetChangedLogistics(logisticsCh)
for changedInfo := range logisticsCh {
t.Log("username:", changedInfo.Username)
for _, rec := range changedInfo.NewRecords {
t.Log(rec)
}
}
}