{"id":23129045,"url":"https://github.com/twiny/flog","last_synced_at":"2025-04-04T06:25:37.532Z","repository":{"id":43047020,"uuid":"437068886","full_name":"twiny/flog","owner":"twiny","description":"A simple logger API.","archived":false,"fork":false,"pushed_at":"2023-07-22T16:25:26.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T17:42:40.915Z","etag":null,"topics":["golang","logger"],"latest_commit_sha":null,"homepage":"","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/twiny.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":"2021-12-10T17:56:55.000Z","updated_at":"2024-11-04T10:44:24.000Z","dependencies_parsed_at":"2023-01-30T18:15:20.859Z","dependency_job_id":null,"html_url":"https://github.com/twiny/flog","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fflog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fflog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fflog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twiny%2Fflog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twiny","download_url":"https://codeload.github.com/twiny/flog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247130965,"owners_count":20888695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["golang","logger"],"created_at":"2024-12-17T10:08:10.364Z","updated_at":"2025-04-04T06:25:37.509Z","avatar_url":"https://github.com/twiny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flog\na simple logger API for Go program that save logs into a file.\n\n**NOTE**: This package is provided \"as is\" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/twiny/flog/issues/new).\n\n## Install\n`go get github.com/twiny/flog`\n\n## API\n```go\nInfo(msg string, fields ...Field)\nError(msg string, fields ...Field)\nFatal(msg string, fields ...Field)\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/twiny/flog\"\n)\n\n// main\nfunc main() {\n\t// config\n\tconf := \u0026flog.Config{\n\t\tDir:    \"./logs\", // log directory\n\t\tPrefix: \"app\",  // prefix\n\t\tRotate: 7, // how many days to store logs\n\t}\n\n\tlogger, err := flog.NewLogger(conf)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer logger.Close()\n\n\tvar x = struct {\n\t\tName string\n\t\tAge  int\n\t\tJobs map[string]any\n\t}{\n\t\tName: \"John Doe\",\n\t\tAge:  22,\n\t\tJobs: map[string]any{\n\t\t\t\"digital marketer\": 2019,\n\t\t\t\"golang developer\": \"github\",\n\t\t},\n\t}\n\n\tf := []flog.Field{\n\t\tflog.NewField(\"hello\", \"world\"),\n\t\tflog.NewField(\"nice\", 123),\n\t\tflog.NewField(\"person\", x),\n\t}\n\n\tlogger.Info(\"from_main\", f...)\n}\n```\n\n## Benchmark\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/twiny/flog\ncpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz\nBenchmarkLogWrite-4       163430              6599 ns/op             718 B/op         11 allocs/op\nPASS\nok      github.com/twiny/flog   1.320s\n```\n\n### Run tests\n```\ntest\ngo test -timeout 30s -run ^TestLogInfoWrite$ github.com/twiny/flog\ngo test -timeout 30s -run ^TestLogErrorWrite$ github.com/twiny/flog\ngo test -timeout 30s -run ^TestLogFatalWrite$ github.com/twiny/flog\n\nbenchmark\ngo test -benchmem -run=^$ -bench ^BenchmarkLogWrite$ github.com/twiny/flog\ngo test -benchmem -run=^$ -bench ^BenchmarkParallelLogWrite$ github.com/twiny/flog\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwiny%2Fflog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwiny%2Fflog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwiny%2Fflog/lists"}