Example #1
0
func initLogger() bool {
	var flags int

	toConsole, err := utils.Config.GetBool("log", "console")
	if err != nil || toConsole {
		flags = logger.L_CONSOLE
	}

	toFile, err := utils.Config.GetBool("log", "file")
	if err != nil || toFile {
		flags = flags | logger.L_FILE
	}

	logFile, err := utils.Config.GetString("log", "filename")
	if err != nil || len(logFile) <= 0 {
		logFile = "log.txt"
	}

	logger.LogFilename = logFile
	logger.Flags = flags

	result := logger.Init()
	if !result {
		logger.Println("logger init faild")
	}

	return result

}
Example #2
0
func initLogger() {
	var writer io.Writer
	if len(configuration.LoggerEngines) != 0 {
		writer, closers = config.ParseLogEngines(configuration.LoggerEngines,
			logger.LogFileName)
		logger.Init(writer)
	}
}
Example #3
0
File: main.go Project: pooya/craft
func main() {
	hostId, port := handleCommandLine()
	node.Init()
	config.Init(fmt.Sprintf("%d_%d", hostId, port))
	node.CheckSelf()
	logger.Init()
	state.Init()
	handler.Init(port)
}
Example #4
0
File: main.go Project: Tangmz/Blog
func main() {
	fmt.Println("Start")
	http.Handle("/", http.FileServer(http.Dir("../../Blog")))
	log.Println("Debug", "action")
	//----------------------- 日志文件初始化 -----------------------------------
	logger.Init()

	//----------------------- 请求处理初始化 -----------------------------------
	baseop.Init()

	//----------------------- 设置路由 -----------------------------------------
	router.Router()

	//----------------------- 数据库初始化 -------------------------------------
	database.Init()

	//----------------------- 监听端口 -----------------------------------------
	http.ListenAndServe(":80", nil)
}
func main() {
	checkUsage()

	if os.Args[1] == "generate" {
		config.Generate()
		os.Exit(0)
	} else {
		this_config, err := config.Load(os.Args[1])

		if err != nil {
			fmt.Println("Error while loading config file:", err)
			os.Exit(1)
		}

		log := logger.Init(this_config.Facility, this_config.LogLevel)

		result := web.Start(this_config.Listen, this_config, log)

		log.Log("crit", fmt.Sprintf("Failed to start: %s", result))
		log.Close()
	}
}