{"id":43056489,"url":"https://github.com/alexisvisco/debug","last_synced_at":"2026-01-31T11:08:02.709Z","repository":{"id":57552115,"uuid":"136835106","full_name":"alexisvisco/debug","owner":"alexisvisco","description":"Golang debug package like https://www.npmjs.com/package/debug","archived":false,"fork":false,"pushed_at":"2018-06-13T16:54:10.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-20T13:54:41.458Z","etag":null,"topics":["debug","golang","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/alexisvisco.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":"2018-06-10T18:38:17.000Z","updated_at":"2018-06-13T16:54:12.000Z","dependencies_parsed_at":"2022-09-26T18:50:32.407Z","dependency_job_id":null,"html_url":"https://github.com/alexisvisco/debug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alexisvisco/debug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisvisco%2Fdebug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisvisco%2Fdebug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisvisco%2Fdebug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisvisco%2Fdebug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexisvisco","download_url":"https://codeload.github.com/alexisvisco/debug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexisvisco%2Fdebug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28939605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T10:18:23.202Z","status":"ssl_error","status_checked_at":"2026-01-31T10:18:22.693Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["debug","golang","logging"],"created_at":"2026-01-31T11:08:02.629Z","updated_at":"2026-01-31T11:08:02.701Z","avatar_url":"https://github.com/alexisvisco.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Debug \n\n[![CircleCI](https://img.shields.io/circleci/project/github/AlexisVisco/debug.svg)](https://circleci.com/gh/AlexisVisco/debug)\n[![Gocover](https://img.shields.io/badge/coverage-100.0%25-brightgreen.svg?style=flat)](https://gocover.io/github.com/AlexisVisco/debug)\n\nA tiny golang debugging utility based on https://github.com/visionmedia/debug principles.\n\n## Installation\n\n`go get github.com/AlexisVisco/Debug`\n\n## Usage\n\ndebug expose some simple functions like Register, Get, Delete to manage debug.\n\nExample [http_debug.go](https://github.com/AlexisVisco/debug/blob/master/examples/http_debug.go)\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\tdebug \"github.com/AlexisVisco/debug\"\n)\n\nvar httpdeb, _ = debug.Register(\"http\")\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hi there, I love %s!\", r.URL.Path[1:])\n\thttpdeb.Log(fmt.Sprintf(\"%s %s\", r.Method, r.URL.String()))\n}\n\nfunc main() {\n\thttp.HandleFunc(\"/\", handler)\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n![pic](https://i.imgur.com/CWJkgrv.jpg)\n\nExample [infinite_debug.go](https://github.com/AlexisVisco/debug/blob/master/examples/http_debug.go)\n\n```go\npackage main\n\nimport (\n\tdebug \"github.com/AlexisVisco/debug\"\n\t\"time\"\n\t\"strconv\"\n\t\"sync\"\n)\n\nvar fivesec, _ = debug.Register(\"5 times\")\nvar nivesec, _ = debug.Register(\"9 times\")\nvar wait sync.WaitGroup\n\nvar five = 0\nvar nine = 0\n\nfunc main() {\n\twait.Add(1)\n\tgo doEvery(5 * time.Second, func(i time.Time) {\n\t\tfivesec.Log(\"5 = \" + strconv.Itoa(five))\n\t\tfive++\n\t})\n\tgo doEvery(9 * time.Second, func(i time.Time) {\n\t\tnivesec.Log(\"9 = \" + strconv.Itoa(nine))\n\t\tnine++\n\t})\n\twait.Wait()\n}\n\nfunc doEvery(d time.Duration, f func(time.Time)) {\n\tfor x := range time.Tick(d) {\n\t\tf(x)\n\t}\n}\n```\n![pic](https://i.imgur.com/YX5lyQw.jpg)\n\nThe DEBUG environment variable is then used to enable these based on space or comma-delimited names.\n\n## Wildcards\nThe `*` character may be used as a wildcard. Suppose for example your library has debuggers named \"connect:bodyParser\", \"connect:compress\", \"connect:session\", instead of listing all three with DEBUG=connect:bodyParser,connect:compress,connect:session, you may simply do DEBUG=connect:*.\n\n## Exclusion\n\nThe `-` prefix character may be used to exclude a debugger.\u003cbr\u003e\nExample `DEBUG=*,-test` =\u003e atest OK, hello OK, test NOT OK\u003cbr\u003e\nYou can combine with wildcard obviously !\n\n## Environment Variables\n\nYou can set a few environment variables that will change the behavior of the debug logging:\n\n| Name      | Purpose                                         |\n|-----------|-------------------------------------------------|\n| `DEBUG`   | Enables/disables specific debugging namespaces. |\n| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY).  |\n| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |\n| `DEBUG_HIDE_LATENCY` | Hide latency at the end of a tty output. |\n\n## Documentation\n\nFunctions:\n* [`NewDebug(name string) *Debug`](#newdebug)\n* [`Register(name string) (*Debug, Err)`](#register)\n* [`Get(name string) (*Debug, Err)`](#get)\n* [`Delete(name string) Err`](#delete)\n* [`Enable()`](#enable)\n* [`Disable()`](#disable)\n\nMethods:\n* [`(d *Debug) Log(message string)`](#log)\n* [`(d *Debug) Sprint(message string)`](#sprint)\n* [`(d *Debug) SetWriter(writer io.Writer, tty bool) *Debug`](#setwriter)\n* [`(d *Debug) SetFdWriter(file *os.File) *Debug`](#setfdwriter)\n\n## Functions\n\n### NewDebug\n\n__Prototype__: `NewDebug(name string) *Debug`\u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nCreate a debug structure without registering it. Cannot be accessible with [`Get`](#get).\nGenerate a random color from 31 to 37 and 91 to 97 as ainsi code.\n\n```go\ndebug := debug.NewDebug(\"woaw\") \n```\n\n### Register\n\n__Prototype__: `Register(name string) (*Debug, Err)` \u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nCreate a debug and registering it. Can be accessible with [`Get`](#get).\n[`NewDebug`](#newdebug) is used to create the structure.\n\n__Error__:\u003cbr/\u003e\nReturn an error if name is already in the registry.\n\n```go\ndebug, err := debug.Create(\"woaw\")\nif err {\n  fmt.Printf(\"name %s already used !\", \"woaw\")\n}\n```\n\n### Get\n\n__Prototype__: `Get(name string) (*Debug, Err)`\u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nGet a debug structure from it name.\n\n__Error__:\u003cbr/\u003e\nReturn an error if name is not in the registry.\n\n```go\ndebug, err := debug.Get(\"woaw\")\nif err {\n  fmt.Printf(\"name %s has not been created !\", \"woaw\")\n}\n```\n\n### Delete\n\n__Prototype__: `Delete(name string) Err` \u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nDelete a debug structure from the registry.\n\n__Error__:\u003cbr/\u003e\nReturn an error if name is not in the registry.\n\n```go\nerr := debug.Delete(\"woaw\")\nif err {\n  fmt.Printf(\"name %s has not been created !\", \"woaw\")\n}\n```\n\n### Enable\n\n__Prototype__: `Enable()` \u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nEnable printing with debug.\n\n```go\ndebug.Enable()\n```\n\n### Disable\n\n__Prototype__: `Disable()`\u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nDisable printing with debug.\n\n```go\ndebug.Disable()\n```\n\n## Methods\n\n### Log\n\n__Prototype__: `(d *Debug) Log(message string`\u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nPrint if debug is active the message with the name of the debug and the latency between the last call if it was activated.\n\n```go\nwoaw, _ := debug.Create(\"woaw\")\n\nwoaw.Log(\"Hola !\")\nwoaw.Log(\"Hola 2 !\")\n```\n\n### Sprint\n\n__Prototype__: `(d *Debug) Sprint(message string)` \u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nReturn the full string that should be printed.\n\n```go\nwoaw, _ := debug.Create(\"woaw\")\n\nstr := waw.Sprint(\"Hola !\")\n```\n\n### SetWriter\n\n__Prototype__: `(d *Debug) SetWriter(writer io.Writer, tty bool) *Debug` \u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nSet the writer, if it's a terminal set to true the next parameter.\n\n```go\nwoaw, _ := debug.Create(\"woaw\")\n\nwoaw.SetWriter(os.Stdout, true)\n```\n\n### SetFdWriter\n\n__Prototype__: `(d *Debug) SetFdWriter(file *os.File) *Debug` \u003cbr/\u003e\n\n__Description__:\u003cbr/\u003e\nThis function will set the writer and determine if the `file.Fd()` is a terminal.\n\n```go\nwoaw, _ := debug.Create(\"woaw\")\n\nwoaw.SetFdWriter(os.Stdout)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexisvisco%2Fdebug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexisvisco%2Fdebug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexisvisco%2Fdebug/lists"}