{"id":37178103,"url":"https://github.com/chuangbo/logruscls","last_synced_at":"2026-01-14T20:45:42.930Z","repository":{"id":57487677,"uuid":"202128735","full_name":"chuangbo/logruscls","owner":"chuangbo","description":"Asynchronise Tencent CLS Hook for logrus","archived":false,"fork":false,"pushed_at":"2019-08-14T05:05:26.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T08:08:05.212Z","etag":null,"topics":["logrus","logrus-hook","tencent-cls"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/chuangbo/logruscls","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chuangbo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-13T11:22:00.000Z","updated_at":"2024-06-20T08:08:05.213Z","dependencies_parsed_at":"2022-08-29T13:30:25.244Z","dependency_job_id":null,"html_url":"https://github.com/chuangbo/logruscls","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chuangbo/logruscls","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuangbo%2Flogruscls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuangbo%2Flogruscls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuangbo%2Flogruscls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuangbo%2Flogruscls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chuangbo","download_url":"https://codeload.github.com/chuangbo/logruscls/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuangbo%2Flogruscls/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logrus","logrus-hook","tencent-cls"],"created_at":"2026-01-14T20:45:42.002Z","updated_at":"2026-01-14T20:45:42.922Z","avatar_url":"https://github.com/chuangbo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tencent CLS Hook for logrus\n[![GoDoc](https://godoc.org/github.com/chuangbo/logruscls?status.svg)](https://godoc.org/github.com/chuangbo/logruscls)\n[![Go Report Card](https://goreportcard.com/badge/github.com/chuangbo/logruscls)](https://goreportcard.com/report/github.com/chuangbo/logruscls)\n\nAsynchronise batch upload logs to [Tencent Cloud CLS](https://cloud.tencent.com/document/product/614) for logrus with configurable batch number and max wait time.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"github.com/chuangbo/logruscls\"\n\tlog \"github.com/sirupsen/logrus\"\n)\n\nfunc main() {\n\t// NewCLSAsyncClient or NewCLSClient\n\tclient, err := logruscls.NewCLSAsyncClient(\n\t\t\"topicID\",\n\t\t\"region\",\n\t\t\"secretID\",\n\t\t\"secretKey\",\n\t\t30, // max number of logs for batch upload\n\t\ttime.Second*30, // max wait time before reach max number of logs\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thook, err := logruscls.NewHook(client)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.AddHook(hook)\n}\n```\n\nOf course the logrus-free golang cls client `CLSClient` and `CLSAsyncClient` are for you to use directly as well if logrus is not your thing.\n\n```go\npackage main\n\nimport (\n\t\"github.com/chuangbo/logruscls\"\n\t\"github.com/chuangbo/logruscls/pb\"\n\t\"github.com/golang/protobuf/proto\"\n)\n\nfunc main() {\n\tclient, err := logruscls.NewCLSAsyncClient(...)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = client.Log(\u0026pb.Log{\n\t\tTime: proto.Int64(time.Now().UnixNano() / int64(time.Millisecond)),\n\t\tContents: []*pb.Log_Content{\n\t\t\t{\n\t\t\t\tKey:   proto.String(\"message\"),\n\t\t\t\tValue: proto.String(\"Hello Logrus\"),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nFor more API please refer to [godoc](https://godoc.org/github.com/chuangbo/logruscls) and [CLS protobuf definition](https://cloud.tencent.com/document/product/614/16873). But please keep in mind, this may never going to be a full-feature CLS client.\n\n## Todos\n\n* ~~signature for headers and query string~~ (md5 doesn't work so kind of pointless)\n* ~~content md5~~ (seems upload using even wrong random md5 checksum work)\n* ~~lz4 compress~~ (doesn't work)\n* tests\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n\nCopyright (c) 2019-present, Chuangbo Li\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuangbo%2Flogruscls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchuangbo%2Flogruscls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuangbo%2Flogruscls/lists"}