{"id":17067795,"url":"https://github.com/kstenerud/go-loggedio","last_synced_at":"2025-07-19T04:33:44.444Z","repository":{"id":137706485,"uuid":"244545729","full_name":"kstenerud/go-loggedio","owner":"kstenerud","description":"Logged I/O for Go","archived":false,"fork":false,"pushed_at":"2020-03-06T05:09:07.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T15:59:32.727Z","etag":null,"topics":["go","golang","logging"],"latest_commit_sha":null,"homepage":null,"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/kstenerud.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-03T04:59:25.000Z","updated_at":"2021-09-09T15:40:48.000Z","dependencies_parsed_at":"2024-06-20T14:22:51.514Z","dependency_job_id":null,"html_url":"https://github.com/kstenerud/go-loggedio","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kstenerud/go-loggedio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kstenerud%2Fgo-loggedio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kstenerud%2Fgo-loggedio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kstenerud%2Fgo-loggedio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kstenerud%2Fgo-loggedio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kstenerud","download_url":"https://codeload.github.com/kstenerud/go-loggedio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kstenerud%2Fgo-loggedio/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265888943,"owners_count":23844533,"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":["go","golang","logging"],"created_at":"2024-10-14T11:11:40.270Z","updated_at":"2025-07-19T04:33:44.248Z","avatar_url":"https://github.com/kstenerud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Logged I/O for Go\n=================\n\nA go module to proxy I/O operations so that they can be reported.\n\nLoggedIO proxies calls to `io.Reader`, `io.Writer`, `io.Closer`, and `net.Conn`\ninterfaces, reporting their read, write, error, and close events.\n\nLoggedIO uses duck typing, meaning that the proxied object is not checked\nfor compatibility until you actually call a method. If you attempt to call\na proxied method that the object doesn't actually implement, it will panic.\nIt's recommended to cast to the expected interface before use for better type\nsafety.\n\nThe following proxy generators are available:\n\n* **Generic:** All reporting behavior is provided by user-defined functions.\n* **StringToLog:** Interprets all data as strings and writes them to the go log.\n* **HexToLog:** Converts all data to hex and writes them to the go log.\n* **StringToLog:** Interprets all data as strings and writes them to the specified `io.Writer`.\n* **HexToLog:** Converts all data to hex and writes them to the specified `io.Writer`.\n* **DumpToWriters:** Dumps all reads and writes to separate `io.Writer` objects.\n* **DumpToFiles:** Dumps all reads and writes to separate files.\n\n\nUsage\n-----\n\n```golang\nfunc Demonstrate() {\n\treaderWriter := \u0026bytes.Buffer{}\n\tvar err error\n\n\t// Log all reads/writes as hex to stdout:\n\tproxy := loggedio.HexToWriter(readerWriter, os.Stdout, \"R [%v]\\n\", \"W [%v]\\n\", \"E [%v: %v]\\n\", \"C\\n\")\n\tif _, err = proxy.Write([]byte{1, 2, 0xae, 0xf1}); err != nil {\n\t\t// TODO\n\t}\n\n\treaderWriter.Reset()\n\n\t// Log all reads/writes as both hex AND strings (chaining together two proxies):\n\tstringProxy := loggedio.StringToWriter(readerWriter, os.Stdout, \"RS [%v]\\n\", \"WS [%v]\\n\", \"E [%v: %v]\\n\", \"C\\n\")\n\thexProxy := loggedio.HexToWriter(stringProxy, os.Stdout, \"RH [%v]\\n\", \"WH [%v]\\n\", \"\", \"\")\n\n\tif _, err = hexProxy.Write([]byte(\"Testing\")); err != nil {\n\t\t// TODO\n\t}\n\n\tif _, err = hexProxy.Write([]byte(\" 1 2 3!\")); err != nil {\n\t\t// TODO\n\t}\n\n\tbuffer := make([]byte, readerWriter.Len())\n\tif _, err = hexProxy.Read(buffer); err != nil {\n\t\t// TODO\n\t}\n}\n```\n\nOutput:\n\n```\nW [01 02 ae f1]\nWS [Testing]\nWH [54 65 73 74 69 6e 67]\nWS [ 1 2 3!]\nWH [20 31 20 32 20 33 21]\nRS [Testing 1 2 3!]\nRH [54 65 73 74 69 6e 67 20 31 20 32 20 33 21]\n```\n\nFor other examples, see the [unit tests](loggedio_test.go).\n\n\nLicense\n-------\n\nMIT License:\n\nCopyright 2020 Karl Stenerud\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkstenerud%2Fgo-loggedio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkstenerud%2Fgo-loggedio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkstenerud%2Fgo-loggedio/lists"}