{"id":26175562,"url":"https://github.com/ichbinleoon/slogx","last_synced_at":"2026-03-12T15:02:42.002Z","repository":{"id":57645475,"uuid":"439980989","full_name":"IchBinLeoon/slogx","owner":"IchBinLeoon","description":"📝🪵 A minimal level based logging library for Go","archived":false,"fork":false,"pushed_at":"2021-12-19T23:48:00.000Z","size":6,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T09:42:54.499Z","etag":null,"topics":["golang","logging"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/IchBinLeoon/slogx","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/IchBinLeoon.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-19T22:22:17.000Z","updated_at":"2023-03-24T22:27:33.000Z","dependencies_parsed_at":"2022-09-08T15:11:39.454Z","dependency_job_id":null,"html_url":"https://github.com/IchBinLeoon/slogx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IchBinLeoon%2Fslogx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IchBinLeoon%2Fslogx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IchBinLeoon%2Fslogx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IchBinLeoon%2Fslogx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IchBinLeoon","download_url":"https://codeload.github.com/IchBinLeoon/slogx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248964266,"owners_count":21190498,"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","logging"],"created_at":"2025-03-11T20:56:57.594Z","updated_at":"2026-03-12T15:02:41.903Z","avatar_url":"https://github.com/IchBinLeoon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slogx\n[![Release](https://img.shields.io/github/v/release/IchBinLeoon/slogx?style=flat-square)](https://github.com/IchBinLeoon/slogx/releases)\n[![Go](https://img.shields.io/github/go-mod/go-version/IchBinLeoon/slogx?style=flat-square)](https://golang.org/)\n[![License](https://img.shields.io/github/license/IchBinLeoon/slogx?style=flat-square)](https://github.com/IchBinLeoon/slogx/blob/main/LICENSE)\n[![Code Size](https://img.shields.io/github/languages/code-size/IchBinLeoon/slogx?style=flat-square)](https://github.com/IchBinLeoon/slogx/blob/main/slogx.go)\n\nA minimal level based logging library for Go.\n\n- [Installation](#Installation)\n- [Example](#Example)\n- [Usage](#Usage)\n    - [Logger](#Logger)\n    - [Log](#Log)\n    - [Level](#Level)\n    - [Format](#Format)\n    - [Output](#Output)\n- [Contribute](#Contribute)\n- [License](#License)\n\n## Installation\n```\ngo get github.com/IchBinLeoon/slogx\n```\n\n## Example\n```go\npackage main\n\nimport \"github.com/IchBinLeoon/slogx\"\n\nfunc main() {\n    logger := slogx.NewLogger(\"EXAMPLE\")\n\n    logger.Error(\"This is Error!\")\n    logger.Errorf(\"This is %s!\", \"Error\")\n\n    logger.Warning(\"This is Warning!\")\n    logger.Warningf(\"This is %s!\", \"Warning\")\n\n    logger.Info(\"This is Info!\")\n    logger.Infof(\"This is %s!\", \"Info\")\n}\n```\nOutput:\n```\n2021-06-08 20:08:19 ERROR main.go:11 EXAMPLE: This is Error!\n2021-06-08 20:08:19 ERROR main.go:12 EXAMPLE: This is Error!\n2021-06-08 20:08:19 WARNING main.go:14 EXAMPLE: This is Warning!\n2021-06-08 20:08:19 WARNING main.go:15 EXAMPLE: This is Warning!\n2021-06-08 20:08:19 INFO main.go:17 EXAMPLE: This is Info!\n2021-06-08 20:08:19 INFO main.go:18 EXAMPLE: This is Info!\n```\n\n## Usage\n### Logger\nCreate a new logger:\n```go\nlogger := slogx.NewLogger(\"awesome name\")\n```\n\nGet an existing logger by its name:\n```go\nlogger := slogx.GetLogger(\"awesome name\")\n```\n\n### Log\nLog a message at Fatal level and exit:\n```go\nlogger.Fatal(\"This is Fatal!\")\nlogger.Fatalf(\"This is %s!\", \"Fatal\")\n```\n\nLog a message at Error level:\n```go\nlogger.Error(\"This is Error!\")\nlogger.Errorf(\"This is %s!\", \"Error\")\n```\n\nLog a message at Warning level:\n```go\nlogger.Warning(\"This is Warning!\")\nlogger.Warningf(\"This is %s!\", \"Warning\")\n```\n\nLog a message at Info level:\n```go\nlogger.Info(\"This is Info!\")\nlogger.Infof(\"This is %s!\", \"Info\")\n```\n\nLog a message at Debug level:\n```go\nlogger.Debug(\"This is Debug!\")\nlogger.Debugf(\"This is %s!\", \"Debug\")\n```\n\nLog a message at a specified level:\n```go\nlogger.Log(slogx.ERROR, \"This is Error!\")\nlogger.Logf(slogx.INFO, \"This is %s!\", \"Info\")\n```\n\n### Level\nThe default logging level is `INFO`.\n\nSet the logging level:\n```go\nlogger.SetLevel(slogx.DEBUG)\n```\n\nSet the logging level from a string:\n```go\nlogger.SetLevel(slogx.ParseLevel(\"DEBUG\"))\n```\n\nGet the current logging level:\n```go\nlevel := logger.GetLevel()\n```\n\n### Format\nSet a custom format:\n```go\nerr := logger.SetFormat(\"[${time}] ${file} (${level}): ${message}\")\nif err != nil {\n    // Handle error...\n}\n```\n|Verb|Description|\n|----|-----------|\n|${time}|The current time|\n|${level}|The logging level|\n|${file}|The file the log statement is in|\n|${line}|The line the log statement is on|\n|${name}|The name of the logger|\n|${message}|The log message|\n\nThe default time format is `2006-01-02 15:04:05`. \n\nTo change the time format:\n```go\nlogger.SetTimeFormat(\"Jan _2 15:04:05\")\n```\nThe time format must be a layout supported by the go time package.\n\n### Output\nThe default output is `Stdout`.\n\nSet the output:\n```go\nf, err := os.OpenFile(\"app.log\", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\nif err != nil {\n    // Handle error...\n}\ndefer f.Close()\n\nlogger.SetOutput(f)\n```\nThe output can be any `io.Writer`.\n\n## Contribute\nContributions are welcome! Feel free to open issues or submit pull requests!\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/IchBinLeoon/slogx/blob/main/LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fichbinleoon%2Fslogx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fichbinleoon%2Fslogx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fichbinleoon%2Fslogx/lists"}