{"id":19124745,"url":"https://github.com/mitinarseny/gol","last_synced_at":"2025-07-16T12:07:56.183Z","repository":{"id":59044692,"uuid":"191926083","full_name":"mitinarseny/gol","owner":"mitinarseny","description":"A small wrapper for standard log package in Go with enhanced prefixes.","archived":false,"fork":false,"pushed_at":"2019-06-30T15:55:59.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-22T13:58:52.328Z","etag":null,"topics":["logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitinarseny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-14T10:42:26.000Z","updated_at":"2019-08-03T13:02:10.000Z","dependencies_parsed_at":"2022-09-11T04:52:29.586Z","dependency_job_id":null,"html_url":"https://github.com/mitinarseny/gol","commit_stats":null,"previous_names":["mitinarseny/golog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mitinarseny/gol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fgol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fgol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fgol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fgol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitinarseny","download_url":"https://codeload.github.com/mitinarseny/gol/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fgol/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265508369,"owners_count":23779133,"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":["logging"],"created_at":"2024-11-09T05:30:22.183Z","updated_at":"2025-07-16T12:07:56.091Z","avatar_url":"https://github.com/mitinarseny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gol [![Build Status](https://img.shields.io/travis/mitinarseny/gol/master.svg?style=flat-square\u0026logo=travis-ci)](https://travis-ci.org/mitinarseny/gol) [![Coverage](https://img.shields.io/codecov/c/github/mitinarseny/gol/master.svg?style=flat-square\u0026logo=codecov\u0026logoColor=success)](https://codecov.io/gh/mitinarseny/gol) [![ColangCI](https://golangci.com/badges/github.com/mitinarseny/gol.svg)](https://golangci.com/r/github.com/mitinarseny/gol) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/mitinarseny/gol)\n\nA small wrapper for standard [log](https://golang.org/pkg/log/) package in Go with enhanced prefixes.\n\n## Install\n```bash\ngo get github.com/mitinarseny/gol\n```\n\n## Documentation\nSee documentation for this package on [GoDoc](https://godoc.org/github.com/mitinarseny/gol).\n\n## Usage\nCreate `gol.Logger` from `log.Logger`:\n```go\nl := gol.New(log.New(os.Stdout, \"\", 0))\n```\nType `gol.Logger` has `*log.Logger` embedded in it, so you can use all functions from [log](https://golang.org/pkg/log/) package.\n\nYou can use following functions to change prefix of logger:\n* `l.SetPersistentPrefix(\"prefix\")`\n* `l.SetPersistentPrefixf(\"%s pattern\")`\n* `l.SetPrefix(\"prefix\")`\n* `l.SetPrefixf(\"%s pattern\")`\n\nAll these functions return `RestoreFunc` which can be used to restore previous prefix.\nIt is recommended to use it with `defer` keyword:\n```go\nfunc someFunc() {\n\tdefer l.SetPrefixf(\"  %s\")()\n\t...\n}\n```\n\n## Example\nConsider an example below:\n```go\n// main.go\nimport (\n\t\"os\"\n\t\"log\"\n\t\"github.com/mitinarseny/gol\"\n)\n\nfunc main() {\n\tl := gol.New(log.New(os.Stdout, \"\", 0))\n\t\n\tr1 := l.SetPersistentPrefix(\"gol \")\n\tl.Println(\"is logger for Go with enhanced prefixes\")\n\t\n\tr2 := l.SetPrefix(\"is cool because \")\n\tl.Println(\"you can grow prefixes easily\")\n\t\n\tr3 := l.SetPrefixf(\"%syou \")\n\tl.Println(\"do not have to repeat yourself\")\n\t\n\tr3()\n\tl.Println(\"it is easy to restore previous prefixes\")\n\t\n\tr2()\n\tl.Println(\"is very cool\")\n\t\n\tr1()\n\tl.Println(\"that's it :)\")\n}\n```\nThis code will produce following output:\n```\ngol is logger for Go with enhanced prefixes\ngol is cool because you can grow prefixes easily\ngol is cool because you do not have to repeat yourself\ngol is cool because a lot of reasnons\ngol is very cool\nthat's it :)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Fgol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitinarseny%2Fgol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Fgol/lists"}