Exemplo n.º 1
0
func init() {

	// initialize structured logging
	structured.AddHookToSyslog("tcp", "localhost:10514", syslog.LOG_EMERG, "mini---project")
	structured.AddHookToElasticsearch("localhost", "9200", "clients", "user", "")

	// seed the random generator to generate IDs
	rand.Seed(time.Now().UTC().UnixNano())

}
Exemplo n.º 2
0
func init() {

	structured.AddHookToSyslog("tcp", "localhost:10514", syslog.LOG_EMERG, "log messages ")
	structured.AddHookToElasticsearch("localhost", "9200", "clients", "ids", "")

	var err error

	//set up the database
	db, err = sql.Open("mysql", "root@tcp(localhost:3306)/logs?parseTime=true")
	if err != nil {
		structured.Error("", "", "can't open databases", 0, nil)
		return
	}

	// seed the random generator to generate IDs
	rand.Seed(time.Now().UTC().UnixNano())

}
Exemplo n.º 3
0
func init() {
	var err error
	// Create a client
	client, err = elastic.NewClient()
	if err != nil {
		fmt.Println(err)
	}

	// Create an index
	_, err = client.CreateIndex("alls").Do()
	if err != nil {
		fmt.Println(err)
	}

	//log debug message to rsyslog file
	structured.AddHookToSyslog("tcp", "localhost:10514", syslog.LOG_EMERG, "live===log")
	//log debug message to os standard
	structured.SetOutput(os.Stderr)
	//log debug message to elasticsearch
	structured.AddHookToElasticsearch("dp-kewei01-dev.sea1.office.priv", "9200", "debug", "log", "")
}