{"id":24196818,"url":"https://github.com/pchchv/golog","last_synced_at":"2025-07-09T20:36:50.360Z","repository":{"id":65423992,"uuid":"525674311","full_name":"pchchv/golog","owner":"pchchv","description":"Simple logging library for golang","archived":false,"fork":false,"pushed_at":"2023-02-24T19:46:02.000Z","size":40,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-05T09:42:00.093Z","etag":null,"topics":["golang","golang-library","golang-package","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pchchv.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}},"created_at":"2022-08-17T06:54:35.000Z","updated_at":"2023-01-22T13:08:56.000Z","dependencies_parsed_at":"2025-01-13T19:38:39.754Z","dependency_job_id":"c79ccab3-d6c0-4874-8315-d54f55911d06","html_url":"https://github.com/pchchv/golog","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"dcc415908a86ad158811f57d6ae16daa2653d191"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pchchv/golog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fgolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fgolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fgolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fgolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pchchv","download_url":"https://codeload.github.com/pchchv/golog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchchv%2Fgolog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264502992,"owners_count":23618674,"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","golang-library","golang-package","logger","logging"],"created_at":"2025-01-13T19:38:25.355Z","updated_at":"2025-07-09T20:36:50.342Z","avatar_url":"https://github.com/pchchv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/pchchv/golog.svg)](https://pkg.go.dev/github.com/pchchv/golog)\n\n# **golog**\n\n### *Simple logging library for golang*\n\n# **Using**\n\n## *Import*\n```go\nimport \"github.com/pchchv/golog\"\n```\n\nCall `golog.{Plain|Info|Debug|Error|Fatal}` with a message.\n\n```go\ngolog.Info(\"Hello world!\")\ngolog.Debug(\"Coordinate: %d, %d\", x, y)\n```\n\nThe default printing format is something like this:\n\n```bash\n2023-01-11 11:59:23.411 [INFO]  main.go:21 | Hello world!\n2023-01-11 11:59:23.412 [DEBUG] main.go:22 | Coordinate: 42, 13\n```\n\nOnly the `golog.Plain` function does not produce leading information (date, log-level, etc.) and just acts like `fmt.Printf` does.\n\n## *Error handling*\n\nRecommended to use [pkg/errors](https://github.com/pkg/errors) package to create and wrap your errors. It enables you to see stack traces.\n\nTo exit on an error, there's the `golog.FatalCheck` function:\n\n```go\nerr := someFunctionCall()\ngolog.FatalCheck(err)\n```\n\nWhen `err` is *not* `nil`, then the error including stack trace will be printed and your application exists with exit code 1.\n\n## *Log level*\n\nSpecify the log level by changing `golog.LogLevel`. Possible value are `golog.LOG_PLAIN`, `golog.LOG_DEBUG`, `golog.LOG_INFO`, `golog.LOG_ERROR` and `golog.LOG_FATAL`.\n\nDepending on the log level, some functions will be quite and do not produce outputs anymore:\n\n| log level | Methods which will produce an output |\n|:--:|:--|\n| `LOG_PLAIN` | `golog.Plain()`\u003csup\u003e\\*\u003c/sup\u003e\u003cbr\u003e`golog.Debug()`\u003cbr\u003e`golog.Info()`\u003cbr\u003e`golog.Error()`\u003cbr\u003e`golog.Fatal()`\u003cbr\u003e`golog.CheckFatal()`\u003cbr\u003e`golog.Stack()` |\n| `LOG_DEBUG` | `golog.Debug()`\u003cbr\u003e`golog.Info()`\u003cbr\u003e`golog.Error()`\u003cbr\u003e`golog.Fatal()`\u003cbr\u003e`golog.CheckFatal()`\u003cbr\u003e`golog.Stack()` |\n| `LOG_INFO` | `golog.Info()`\u003cbr\u003e`golog.Error()`\u003cbr\u003e`golog.Fatal()`\u003cbr\u003e`golog.CheckFatal()`\u003cbr\u003e`golog.Stack()` |\n| `LOG_ERROR` | `golog.Error()`\u003cbr\u003e`golog.Fatal()`\u003cbr\u003e`golog.CheckFatal()`\u003cbr\u003e`golog.Stack()` |\n| `LOG_FATAL` | `golog.Fatal()`\u003csup\u003e\\*\\*\u003c/sup\u003e\u003cbr\u003e`golog.CheckFatal()`\u003csup\u003e\\*\\*\u003c/sup\u003e |\n\\* Prints to stdout but without any tags in front\n\\*\\* This will print the error and call `os.Exit(1)`\n\n## *Function suffixes / Variants*\n\nSome functions have a suffix with slightly different behavior.\n\n#### For non-fatal functions:\n\n* Suffix `b`: Acts like the normal function, but in order to print the correct caller you can go **b**ack in the stack.\n\n#### For fatal-functions:\n\n* Suffix `f`: Acts like the normal function, but after printing the stack, the given format string will be evaluated and printed as well.\n\n## *Change general output format*\n\nThe format can be changed by implementing the printing function specified in the `golog.FormatFunctions` array.\n\nExmaple: To specify your own debug-format:\n\n```go\nfunc main() {\n    // Whenever golog.Debug is called, our simpleDebug method is used to produce the output.\n    golog.FormatFunctions[golog.LOG_DEBUG] = simpleDebug\n    \n    golog.Debug(\"Hello world!\")\n    }\n    \n    func simpleDebug(writer *os.File, time, level string, maxLength int, caller, message string) {\n    // Don't forget the \\n at the end ;)\n    fmt.Fprintf(writer, \"Debug: %s\\n\", message)\n}\n```\n\nThis example will print:\n\n```bash\nDebug: Hello world!\n```\n\n## *Change time format*\n\nTo change only the time format, change the value of the `golog.DateFormat` variable. The format of this variable if the\nformat described in the [time package](https://golang.org/pkg/time/).\n\nExample:\n\n```go\nfunc main() {\n    golog.DateFormat = \"02.01.2006 at 15:04:05\"\n    \n    golog.Debug(\"Hello world!\")\n}\n```\n\nThis will produce:\n\n```bash\n11.01.2023 at 11:34:22 [DEBUG] main.go:37 | Hello world!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchchv%2Fgolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpchchv%2Fgolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchchv%2Fgolog/lists"}