Exemplo n.º 1
0
// initialize the logger
func Init(keylist []string) *logger.LogWriter {

	if loggerInitialized == true {
		if keylist != nil {
			QueryLogger.EnableKeys(keylist)
		}

		return QueryLogger
	}

	var err error
	QueryLogger, err = logger.NewLogger("cbq-server", logger.LevelInfo)
	if err != nil {
		fmt.Printf("Cannot create logger instance")
		return nil
	}

	// set logging to file
	QueryLogger.SetFile()
	if keylist != nil {
		QueryLogger.EnableKeys(keylist)
	} else {
		QueryLogger.EnableKeys([]string{PARSER, COMPILER, PIPELINE, ALGEBRA, DATASTORE})
	}

	loggerInitialized = true
	return QueryLogger
}
func main() {
	http.HandleFunc("/command/", cmdHandler)
	var err error
	lw, err = logger.NewLogger("ExampleServer", logger.LevelInfo)
	if err != nil {
		fmt.Printf("Cannot create logger instance %s", err.Error())
		panic("die")
	}
	lw.EnableKeys([]string{ES})
	lw.SetFile()
	sc, err = stats.NewStatsCollector(ES)
	if err != nil {
		lw.LogError("", ES, "Unable to initialize stats module %s", err.Error())
	}

	sc.AddStatKey("Requests", 0)
	sc.AddStatKey("Success", 0)
	sc.AddStatKey("Failures", 0)
	sc.AddStatKey("Server Port", 9191)
	sc.AddStatKey("bytesReceived", 0)
	sc.AddStatKey("bytesSent", 0)

	lw.LogInfo("", ES, "Example Server starting on port 9191")
	http.ListenAndServe(":9191", nil)
}
Exemplo n.º 3
0
func main() {

	r := mux.NewRouter()
	r.HandleFunc("/logger/{module}", HandleLoggerCmds).Methods("GET", "PUT", "POST")
	r.HandleFunc("/stats/{module}", HandleStatsCmds).Methods("GET", "PUT", "POST")
	http.Handle("/", r)

	rl, err := logger.NewLogger(DEFAULT, logger.LevelDebug)
	if err != nil {
		panic_msg := fmt.Sprintf("Cannot intialize logger %s", err.Error())
		panic(panic_msg)
	}
	rl.SetFile()
	rl.EnableKeys([]string{DEFAULT, LOGGER, "Stats"})

	rl.LogInfo("", DEFAULT, "Retriever Server started")

	http.ListenAndServe(":8080", nil)
}
func main() {
	var err error
	lw, err = logger.NewLogger("ExampleClient", logger.LevelInfo)
	if err != nil {
		fmt.Printf("Cannot create logger instance %s", err.Error())
		panic("die")
	}
	lw.EnableKeys([]string{EC})
	lw.SetFile()
	sc, err = stats.NewStatsCollector(EC)
	if err != nil {
		lw.LogError("", EC, "Unable to initialize stats module %s", err.Error())
	}

	sc.AddStatKey(STAT_REQUESTS, 0)
	sc.AddStatKey(STAT_FAILURES, 0)
	sc.AddStatKey(STAT_BYTESTRANS, 0)
	sc.AddStatKey(STAT_BYTESRECEIVED, 0)
	do_requests(1, "http://localhost:9191/command/")
}
Exemplo n.º 5
0
func init() {
	ul, _ = logger.NewLogger("upr_client", logger.LevelInfo)
}