{"id":19302474,"url":"https://github.com/bitlytwiser/slogger","last_synced_at":"2025-06-10T19:39:23.890Z","repository":{"id":65141010,"uuid":"582844911","full_name":"BitlyTwiser/slogger","owner":"BitlyTwiser","description":"Wrapper around the experimental Golang slog package","archived":false,"fork":false,"pushed_at":"2022-12-28T21:22:08.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-24T01:51:06.356Z","etag":null,"topics":["golang","logging","logging-library","slog"],"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/BitlyTwiser.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-12-28T02:53:44.000Z","updated_at":"2023-04-21T02:22:33.000Z","dependencies_parsed_at":"2023-01-10T14:15:44.589Z","dependency_job_id":null,"html_url":"https://github.com/BitlyTwiser/slogger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitlyTwiser%2Fslogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitlyTwiser%2Fslogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitlyTwiser%2Fslogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitlyTwiser%2Fslogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BitlyTwiser","download_url":"https://codeload.github.com/BitlyTwiser/slogger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitlyTwiser%2Fslogger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259137548,"owners_count":22810729,"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","logging-library","slog"],"created_at":"2024-11-09T23:22:18.802Z","updated_at":"2025-06-10T19:39:23.824Z","avatar_url":"https://github.com/BitlyTwiser.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slogger [![Go Report Card](https://goreportcard.com/badge/github.com/BitlyTwiser/slogger)](https://goreportcard.com/report/github.com/BitlyTwiser/slogger)\n```\n  .--.--.     ,--,                                                      \n /  /    '. ,--.'|                                                      \n|  :  /`. / |  | :     ,---.                                    __  ,-. \n;  |  |--`  :  : '    '   ,'\\   ,----._,.  ,----._,.          ,' ,'/ /| \n|  :  ;_    |  ' |   /   /   | /   /  ' / /   /  ' /   ,---.  '  | |' | \n \\  \\    `. '  | |  .   ; ,. :|   :     ||   :     |  /     \\ |  |   ,' \n  `----.   \\|  | :  '   | |: :|   | .\\  .|   | .\\  . /    /  |'  :  /   \n  __ \\  \\  |'  : |__'   | .; :.   ; ';  |.   ; ';  |.    ' / ||  | '    \n /  /`--'  /|  | '.'|   :    |'   .   . |'   .   . |'   ;   /|;  : |    \n'--'.     / ;  :    ;\\   \\  /  `---`-'| | `---`-'| |'   |  / ||  , ;    \n  `--'---'  |  ,   /  `----'   .'__/\\_: | .'__/\\_: ||   :    | ---'     \n             ---`-'            |   :    : |   :    : \\   \\  /           \n                                \\   \\  /   \\   \\  /   `----'            \n                                 `--`-'     `--`-'                      \n```\nThe logger library using the experimental Golang slog package\n\n## Usage:\n- The package was designed to be a simple interface over the slog package extracing out some if the discoverability features and crafting a simple, easy logger.\n- creating a new logger with ```NewLogger``` function. The input is an io.Writer, so stdout or a file work (any any io.Writer implementation)\n- All variadic values passed to the ```LogEvent```/```LogError``` functions will be treated as key value pairs, any additional values, that are not mapped to their preceeding values, are added as \"misc\" fields to the JSON return.\n\n### Example Usage:\n- create a logger with ```slogger.NewLogger(os.Stdout)```\n- or log to a file:\n```\nf, _ := os.OpenFile(testFile, os.O_RDWR|os.O_TRUNC, os.ModeAppend)\nlog := slogger.NewLogger(f)\nstdoutLogger.LogEvent(\"info\", \"Send data to file\") \n```\n- slogger will accept any number of arbitrary elements and create a json structure from the arguments to the LogEvent functions.\n- i.e.\n```\nstdoutLogger.LogEvent(\"info\", \"Something\", \"one\", \"two\", \"Another\", false, \"four\", true)\n```\noutput:\n```\nstdoutLogger.LogEvent(\"info\", \"Something four\", \"one\", \"two\", \"Another\", false, \"four\", true)\n```\n\n- You can also pass a map to  the LogEvent functions as unput:\n```\nstdoutLogger.LogEvent(\"info\", \"Something four\", map[string]any{\"one\": false})\n```\noutput: \n```\n{\"time\":\"2022-12-27T19:19:22.711393515-08:00\",\"level\":\"INFO\",\"msg\":\"Something four\",\"one\":false}\n```\n- You can even pass a combination of map strings:\n```\nstdoutLogger.LogEvent(\"warn\", \"aaaa\", \"key\", \"value\", \"AnotherKey\", false, \"four\", 123123, map[string]any{\"testOne\": 42069, \"testTwo\": false})\n```\noutput:\n```\nstdoutLogger.LogEvent(\"warn\", \"aaaa\", \"key\", \"value\", \"AnotherKey\", false, \"four\", 123123, map[string]any{\"testOne\": 42069, \"testTwo\": false})\n```\n\n- Example of Misc fields:\n```\n{\"time\":\"2022-12-27T18:56:27.543409183-08:00\",\"level\":\"INFO\",\"msg\":\"Something four\",\"one\":\"two\",\"Another\":false,\"four\":true,\"miscFields\":\"bob\"}\n```\n## Output:\n- Example test output:\n```\n{\"time\":\"2022-12-27T18:56:27.543409183-08:00\",\"level\":\"INFO\",\"msg\":\"Something four\",\"one\":\"two\",\"Another\":false,\"four\":true,\"miscFields\":\"bob\"}\n{\"time\":\"2022-12-27T18:56:27.543564927-08:00\",\"level\":\"INFO\",\"msg\":\"Something four\",\"one\":\"two\",\"Another\":false,\"four\":true}\n{\"time\":\"2022-12-27T18:56:27.543572397-08:00\",\"level\":\"INFO\",\"msg\":\"Something four\",\"one\":false,\"Another\":false,\"four\":true}\n{\"time\":\"2022-12-27T18:56:27.543577644-08:00\",\"level\":\"INFO\",\"msg\":\"A thing\",\"key\":\"value\",\"AnotherKey\":false,\"four\":123123,\"more\":\"\",\"MORETEST\":123123,\"TestAgain\":false,\"miscFields\":123123}\n{\"time\":\"2022-12-27T18:56:27.543583676-08:00\",\"level\":\"WARN\",\"msg\":\"aaaa\",\"AnotherKey\":false,\"four\":123123,\"testOne\":42069,\"testTwo\":false,\"key\":\"value\"}\n{\"time\":\"2022-12-27T18:56:27.543587977-08:00\",\"level\":\"ERROR\",\"msg\":\"error\",\"err\":\"something died\"}\n{\"time\":\"2022-12-27T18:56:27.54359305-08:00\",\"level\":\"ERROR\",\"msg\":\"error\",\"1\":2,\"3\":\"masdasd\",\"err\":\"something died\"}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitlytwiser%2Fslogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitlytwiser%2Fslogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitlytwiser%2Fslogger/lists"}