{"id":31286916,"url":"https://github.com/cqhudson/logger","last_synced_at":"2025-09-24T10:57:30.994Z","repository":{"id":315828516,"uuid":"1060959550","full_name":"cqhudson/logger","owner":"cqhudson","description":"logger is a toggleable logging package that wraps Go's built-in log package.","archived":false,"fork":false,"pushed_at":"2025-09-21T02:31:15.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-21T02:35:56.499Z","etag":null,"topics":["go","go-lib","go-library","go-package","go-packages","goland-packages","golang","golang-lib","golang-library","golang-package","log","logger","logging","logging-library"],"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/cqhudson.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-21T00:18:46.000Z","updated_at":"2025-09-21T02:31:18.000Z","dependencies_parsed_at":"2025-09-21T02:35:58.027Z","dependency_job_id":"a799abc7-fbcc-496e-ae74-a89e48bfd7d5","html_url":"https://github.com/cqhudson/logger","commit_stats":null,"previous_names":["cqhudson/logger"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/cqhudson/logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqhudson%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqhudson%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqhudson%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqhudson%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cqhudson","download_url":"https://codeload.github.com/cqhudson/logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqhudson%2Flogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276737507,"owners_count":25695699,"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","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","go-lib","go-library","go-package","go-packages","goland-packages","golang","golang-lib","golang-library","golang-package","log","logger","logging","logging-library"],"created_at":"2025-09-24T10:57:28.129Z","updated_at":"2025-09-24T10:57:30.985Z","avatar_url":"https://github.com/cqhudson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logger - toggleable logging in Go!\n\n**logger** was developed to enable toggleable logging in your Go program via a simple bool flag. The package just wraps the standard [log](https://pkg.go.dev/log) package provided by Go.\n\n## Usage\n\n1 - add `\"github.com/cqhudson/logger\"` to your package imports list\n\n2 - instantiate a new logger variable with `logger.NewLogger(enablePrint, enablePanic, enableFatal)`, passing in `true` or `false` to enable or disable different logging types.\n\n```go\npackage main\n\nimport (\n    \"github.com/cqhudson/logger\"\n)   \n\nfunc main() {\n    \n    // Instantiate a new logger using NewLogger(enablePrint, enablePanic, enableFatal)\n    l := logger.NewLogger(true, false, true)\n\n    // Set a prefix\n    const prefix string = \"[main function]\"\n    l.SetPrefix(prefix)\n\n    // Set some flags\n    l.SetFlags(logger.Lshortfile | logger.Ltime | logger.Lmicroseconds | logger.Lmsgprefix)\n\n    // log.Print\n    l.Print(\"This is a test of Print\")\n\n\n    // log.Printf\n    s := \"Printf\"\n    l.Printf(\"This is a test of %s\", s)\n\n\n    // log.Println\n    l.Println(\"This is a test of Println\")\n\n\n    // log.Panic\n    l.Panic(\"This is a test of Panic\")\n\n\n    // log.Panicf\n    s = \"Panicf\"\n    l.Panicf(\"This is a test of %s\", s)\n\n\n    // log.Panicln\n    l.Panicln(\"This is a test of Panicln\")\n\n\n    // log.Fatal\n    l.Fatal(\"This is a test of Fatal\")\n\n\n    // log.Fatalf\n    s = \"Fatalf\"\n    l.Fatalf(\"This is a test of %s\", s)\n\n\n    // log.Fatalln\n    l.Fatalln(\"This is a test of Fatalln\")\n}\n```\n\n## Why use logger over Go's builtin log package?\n\nlogger can be toggled using a boolean value. This allows for a cleaner codebase with less code duplication, with an easy way to toggle it on or off.\n\n### Example:\n\nLogging with Go's log package:\n\n```go\nshouldLog := true\n\nif shouldLog == true {\n  log.Print(\"About to do something\")\n}\n\n...\ndo something\ndo something\ndo something\n...\n\nif shouldLog == true {\n  log.Print(\"Finished doing something\")\n}\n```\n\nLogging with logger:\n\n```go\nlogPrints := true\nlogPanics := false\nlogFatals := false\nl := logger.NewLogger(logPrints, logPanics, logFatals)\n\nl.Print(\"About to do something\")\n\n...\ndo something\ndo something\ndo something\n...\n\nl.Print(\"Finished doing something\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcqhudson%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcqhudson%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcqhudson%2Flogger/lists"}