{"id":41145766,"url":"https://github.com/func25/batchlog","last_synced_at":"2026-01-22T18:55:44.791Z","repository":{"id":41959304,"uuid":"482747403","full_name":"func25/batchlog","owner":"func25","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-14T16:57:25.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-21T09:42:12.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/func25.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":"2022-04-18T06:58:41.000Z","updated_at":"2022-04-19T03:34:06.000Z","dependencies_parsed_at":"2022-08-12T00:40:43.927Z","dependency_job_id":null,"html_url":"https://github.com/func25/batchlog","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/func25/batchlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/func25%2Fbatchlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/func25%2Fbatchlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/func25%2Fbatchlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/func25%2Fbatchlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/func25","download_url":"https://codeload.github.com/func25/batchlog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/func25%2Fbatchlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28668643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T17:07:18.858Z","status":"ssl_error","status_checked_at":"2026-01-22T17:05:02.040Z","response_time":144,"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":[],"created_at":"2026-01-22T18:55:44.112Z","updated_at":"2026-01-22T18:55:44.771Z","avatar_url":"https://github.com/func25.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# batchlog\n\nbatchlog is used to batch the logs (built on top of zerolog), avoid spamming \n\n* [Installation](#installation)\n* [Samples](#samples)\n \t* [Batching](#batching)\n\t* [Grouping](#grouping)\n* [Status](#status-pre-release)\n\n\n## Installation\n\n`go get github.com/func25/batchlog`\n\n## Samples\n\n### Batching\n\nBatch with three variables: \"tokenId\", \"isBatch\" and \"message\"\n```go\nlogger := batchlog.NewLogger()\nlogger.Debug().BatchStr(\"tokenId\", \"1\").BatchBool(\"isBatch\", false).BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"1\").BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hellok\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Error().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Debug().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\nlogger.Info().BatchStr(\"tokenId\", \"2\").BatchMsg(\"hello\")\n```\n\nThe result will be:\n```\n{\"level\":\"info\",\"tokenId\":\"2\",\"message\":\"hello\",\"__repeat\":1}\n{\"level\":\"error\",\"tokenId\":\"2\",\"message\":\"hello\",\"__repeat\":1}\n{\"level\":\"debug\",\"tokenId\":\"2\",\"message\":\"hellok\",\"__repeat\":1}\n{\"level\":\"debug\",\"tokenId\":\"2\",\"message\":\"hello\",\"__repeat\":6}\n{\"level\":\"debug\",\"tokenId\":\"1\",\"message\":\"hello\",\"__repeat\":1}\n{\"level\":\"debug\",\"tokenId\":\"1\",\"isBatch\":false,\"message\":\"hello\",\"__repeat\":1}\n```\n\n### Grouping\n\nThis sample will batch first 20 messages in 1 batch and also create group of ids for the log\n```go\nlogger := batchlog.NewLogger(batchlog.OptTimeout(time.Hour))\nfor i := 0; i \u003c 30; i++ {\n\ttime.Sleep(1500 * time.Millisecond)\n\tlogger.Debug().BatchStr(\"tokenID\", \"123456\").GroupInt(\"id\", i).BatchMsg(\"hello\")\n}\n```\n\n```go\n{\"level\":\"debug\",\"tokenID\":\"123456\",\"message\":\"hello\",\"__repeat\":20,\"id\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\",\"17\",\"18\",\"19\"]}\n{\"level\":\"debug\",\"tokenID\":\"123456\",\"message\":\"hello\",\"__repeat\":10,\"id\":[\"20\",\"21\",\"22\",\"23\",\"24\",\"25\",\"26\",\"27\",\"28\",\"29\"]}\n```\n\n## Status: pre-release\nThis lib is under developing, please notice when using it\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunc25%2Fbatchlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunc25%2Fbatchlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunc25%2Fbatchlog/lists"}