Skip to content

comlibs/ali_log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ali_log

Useage

package main

import (
	"fmt"
	"github.com/comlibs/ali_log"
	"time"
)

type appConf struct {
	Url             string
	AccessKey       string
	AccessKeySecret string
	LogStore        string
	Topic           string
	C               int
	AliLogMapChan   chan map[string]string
}

func main() {
	conf := appConf{
		Url:             "vslog.cn-hangzhou.log.aliyuncs.com",
		AccessKey:       "xxxxxxxxxxxxxxxxxxxxxx",
		AccessKeySecret: "xxxxxxxxxxxxxxxxxxxxxx",
		LogStore:        "go-log-service",
		Topic:           "async-service",
		C:               10,
	}

	logStore := ali_log.NewLogstore(
		conf.LogStore,
		ali_log.NewAliLogClient(
			conf.Url,
			conf.AccessKey,
			conf.AccessKeySecret,
		))

	conf.AliLogMapChan = make(chan map[string]string, conf.C)
	ali_log.AliLogRecordGoroutine(
		conf.Topic,
		logStore,
		conf.AliLogMapChan)

	for i := 0; i<100; i++ {
		conf.AliLogMapChan <- map[string]string{
			"IP":             "192.168.1.70",
			"OccurTimeStamp": fmt.Sprintf("%v", time.Now().Unix()),
			"AppName":        "logs",
			"OptName":        "test",
			"InputParams":    "InputParams-test",
			"Err":            "success",
		}
	}
}

About

useful for write log to ali yun log service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages