{"id":46743802,"url":"https://github.com/williabk198/jaglogger","last_synced_at":"2026-03-09T18:43:13.794Z","repository":{"id":57709851,"uuid":"510197380","full_name":"williabk198/jaglogger","owner":"williabk198","description":"A simple and extensible logging library for Go","archived":false,"fork":false,"pushed_at":"2022-12-01T02:35:02.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T12:57:46.901Z","etag":null,"topics":["go","golang","logger","logging"],"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/williabk198.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-07-04T03:19:32.000Z","updated_at":"2022-07-04T04:32:11.000Z","dependencies_parsed_at":"2023-01-22T09:00:29.108Z","dependency_job_id":null,"html_url":"https://github.com/williabk198/jaglogger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/williabk198/jaglogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williabk198%2Fjaglogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williabk198%2Fjaglogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williabk198%2Fjaglogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williabk198%2Fjaglogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williabk198","download_url":"https://codeload.github.com/williabk198/jaglogger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williabk198%2Fjaglogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30307584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T17:35:44.120Z","status":"ssl_error","status_checked_at":"2026-03-09T17:35:43.707Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["go","golang","logger","logging"],"created_at":"2026-03-09T18:43:13.117Z","updated_at":"2026-03-09T18:43:13.784Z","avatar_url":"https://github.com/williabk198.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![go.mod](https://img.shields.io/github/go-mod/go-version/williabk198/jaglogger)](go.mod)\n[![go report](https://goreportcard.com/badge/github.com/williabk198/jaglogger)](https://goreportcard.com/report/github.com/williabk198/jaglogger)\n[![test status](https://github.com/williabk198/jaglogger/workflows/test/badge.svg)](https://github.com/williabk198/jaglogger/actions)\n[![LICENSE](https://img.shields.io/github/license/williabk198/jaglogger)](LICENSE) \n\n# Just Another Go(JAG) Logger\nJAG Logger is built on top of Go's existing `log` package, \nand aims to provide a simple and extensible solution for your logging needs.\n\n## Usage\n\n### Default Logger\nIf you just want a basic logger to use for your application, you can initialize the JAG Logger like so:\n```go\nlogger := jaglogger.NewLogger(jaglogger.LogLevelInfo)\n```\nThe parameter handed to `NewLogger` is the lowest logger level priority that will be handled. \nSo, for the above example, only log priority levels of `Info` and above will be handled. \nThe others (just the `Debug` log priority level, in this case) will be discarded.\n\nUsing this default impolementation, the log levels of `Critical`, `Error` and `Warning` will print to \n`os.Stderr`.  The `Notice`, `Info` and `Debug` log levels will print to `os.Stdout`. \nAlso, using this default implementation, the log entries will be prefixed with `[\u003clevel_name\u003e]`\nwhere `\u003clevel_name\u003e` is the log level name in all caps (e.g. `Critical` will be `[CRITICAL]`), \nand the log flags being used are `log.Ldate`, `log.Ltime`, `log.Llongfile`.\n\nMeaning the output will look something akin to this:\n```\n[INFO]2022/07/03 22:05:03 /path/to/workspace/main.go:8: test\n```\n\n### Customized Logger\nIf the default logger that JAG Logger provides isn't quite what yor are looking for,\nthere are a handful of ways, to customize your experience.\n\n#### Setting Log Level Customizations\nTo customize what gets printed out and where at each logging level, \nyou can utilize the folllowing functions when inializing the logger with `jaglogger.NewLogger`: \n`SetCriticalLoggerOpt`, `SetErrorLoggerOpt`, `SetWarningLoggerOpt`, `SetNoticeLoggerOpt`, `SetInfoLoggerOpt`,\nand `SetDebugLoggerOpt`.\n\n**_Example_**:\n```go\nfile, err := os.Create(\"./error.log\")\nif err != nil {\n  // handle error...\n}\n\nlogger := jaglogger.NewLogger(\n  jaglogger.LogLevelInfo,\n  SetErrorLoggerOpt(jaglogger.Config{Outputs: []io.Writer{file}}),\n)\n```\nAlong with the output(s) the logger prints to, you can also up date the log flags, and the prefix of the logger using the `Flags` and `Prefix` properties of `jaglogger.Config` struct respectively.\n\n**_Another Example_**:\n```go\nlogger := jaglogger.NewLogger(\n  jaglogger.LogLevelInfo,\n  SetErrorLoggerOpt(\n    jaglogger.Config{Outputs: []io.Writer{file}, Prefix: \"SOME_ERROR_PREFIX\", Flags: log.LstdFlags},\n  ),\n)\n```\n\n**_NOTE_**: Any values left blank in the `jaglogger.Config` struct will be filled in with default values during\nthe execution of `jaglogger.NewLogger`\n\n#### Writing logs to multiple locations\nAs yoy may have noticed with the previous examples, you can have logs write to more than one place if need be. If the need arises in which you do need to write a log to more than one place, this is how you can do so:\n```go\nfile, err := os.Create(\"./error.log\")\nif err != nil {\n  // handle error...\n}\n\njaglogger.NewLogger(\n  jaglogger.LogLevelInfo,\n  SetErrorLoggerOpt(\n    jaglogger.Config{Outputs: []io.Writer{file, os.Stderr}},\n  ),\n)\n```\nYep, it's really that simple. As long as where you need to write to implements the `io.Writer` interface,\nyou can just simply plug it into the `Outputs` property of the `jaglogger.Config`.\n\n\n#### Overriding Defaults\nIf you wish to update the default values that are used when a `jaglogger.Config` field is left balnk, \nthen JAG Logger has you covered there as well. These are the following functions you can pass to the \n`jaglogger.NewLogger` function to modify the default values: `SetDefaultErrorOutputsOpt`,\n`SetDefaultNonErrorOutputsOpt`, and `SetDefaultFlagsOpt`\n\n**_Example_**:\n```go\nlogFile, err := os.Create(\"./some.log\")\nif err != nil {\n  // handle error...\n}\n\nerrLogFile, err := os.Create(\"./error.log\")\nif err != nil {\n  // handle error...\n}\n\nlogger := jaglogger.NewLogger(\n  jaglogger.LogLevelInfo,\n  jaglogger.SetDefaultNonErrorOutputsOpt([]io.Writer{logFile}),\n  jaglogger.SetDefaultErrorOutputsOpt([]io.Witer{errLogFile}),\n  jaglogger.SetDefaultFlagsOpt(log.LstdFlags),\n)\n```\n\nThe above will result in the `Critical`, `Error` and `Warning` log levels being printed to the `error.log` file\nwith the `log.LstdFlags` flags, and `Notice`, `Info` and `Debug` will be writen to the `some.log` file in with\nthe `log.LstdFlag` as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliabk198%2Fjaglogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliabk198%2Fjaglogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliabk198%2Fjaglogger/lists"}