{"id":19607004,"url":"https://github.com/codemedic/go-log","last_synced_at":"2025-06-19T16:34:56.949Z","repository":{"id":48590497,"uuid":"386330757","full_name":"codemedic/go-log","owner":"codemedic","description":"Levelled logger for Go; wraps the standard logger.","archived":false,"fork":false,"pushed_at":"2025-05-07T07:27:29.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T08:31:43.020Z","etag":null,"topics":["golang","logging","logging-library","syslog"],"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/codemedic.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}},"created_at":"2021-07-15T15:04:48.000Z","updated_at":"2025-05-07T07:27:33.000Z","dependencies_parsed_at":"2025-04-24T22:29:10.527Z","dependency_job_id":"9d2ad677-b9ac-4aa3-aad4-d76ed1f93881","html_url":"https://github.com/codemedic/go-log","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/codemedic/go-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemedic%2Fgo-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemedic%2Fgo-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemedic%2Fgo-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemedic%2Fgo-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemedic","download_url":"https://codeload.github.com/codemedic/go-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemedic%2Fgo-log/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260787236,"owners_count":23063076,"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","logging","logging-library","syslog"],"created_at":"2024-11-11T10:08:16.498Z","updated_at":"2025-06-19T16:34:51.940Z","avatar_url":"https://github.com/codemedic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Log\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/codemedic/go-log.svg)](https://pkg.go.dev/github.com/codemedic/go-log)\n[![license](https://img.shields.io/github/license/codemedic/go-log?style=flat)](https://raw.githubusercontent.com/codemedic/go-log/master/LICENSE)\n\nGoLog adds level based logging to logger(s) from standard library.\n\nGoLog's API is designed to be expressive with sensible configuration defaults and to be easy to use.\n\n## Installation\n\n    go get -u github.com/codemedic/go-log\n\n## Getting Started\n\nTo get started, import the library and use one of the constructor functions, wrapped with `log.Must`. Make sure the\nlogger is closed, once you are done with it, using `defer l.Close()`. Now you are all set to start logging.\n\n#### Example\n\n```go\npackage main\n\nimport golog \"github.com/codemedic/go-log\"\n\nfunc main() {\n  // create syslog logger\n  l := golog.Must(golog.NewSyslog())\n  \n  // make sure resources are freed up when we are done\n  defer l.Close()\n\n  // hello to the world\n  l.Print(\"hello world!\")\n}\n```\n\n\u003e **NOTE**\u003cbr/\u003e\n\u003e Functions `log.Print` and `log.Printf` logs to `Debug` level by default. It is preferable to use a method that log to\n\u003e a specific level. The level logged to by `log.Print` and `log.Printf` can be changed using [`WithPrintLevel`](https://pkg.go.dev/github.com/codemedic/go-log#WithPrintLevel).\n\nYou can find more [examples here](https://pkg.go.dev/github.com/codemedic/go-log#pkg-examples).\n\n## Leveled Logging\n\nThe methods below provides leveled logging. They follow the same pattern as `fmt.Print` and `fmt.Printf` and uses the\nsame format specification.\n\n```go\n// Log string message at specific levels\nDebug(value ...interface{})\nInfo(value ...interface{})\nWarning(value ...interface{})\nError(value ...interface{})\n\n// Log formatted string message at specific levels, similar to log.Printf from standard library\nDebugf(format string, value ...interface{})\nInfof(format string, value ...interface{})\nWarningf(format string, value ...interface{})\nErrorf(format string, value ...interface{})\n```\n\n#### Example\n\n```go\npackage main\n\nimport (\n  \"errors\"\n  golog \"github.com/codemedic/go-log\"\n)\n\nfunc main() {\n  l := golog.Must(golog.NewSyslog())\n  defer l.Close()\n\n  l.Debug(\"debug message\")\n  l.Debugf(\"formatted %s message\", \"debug\")\n\n  l.Info(\"informational message\")\n  l.Infof(\"formatted %s message\", \"informational\")\n\n  l.Warning(\"warning message\")\n  l.Warningf(\"formatted %s message\", \"warning\")\n\n  l.Error(\"error message\")\n  l.Errorf(\"formatted %v message\", errors.New(\"error\"))\n}\n```\n\n## Options / Settings\n\nSee [documentation](https://pkg.go.dev/github.com/codemedic/go-log#Option) for all available `Options`.\n\n#### Example\n\n```go\npackage main\n\nimport golog \"github.com/codemedic/go-log\"\n\nfunc main() {\n  l := golog.Must(golog.NewSyslog(\n    golog.OptionsMust(golog.Options(\n      golog.WithLevelFromEnv(\"LOG_THRESHOLD\", golog.Info),\n      golog.WithSourceLocationFromEnv(\"LOG_CALLER_LOCATION\", \"short\"),\n      golog.WithSyslogTag(\"my-test-app\"),\n    ))))\n  defer l.Close()\n\n  l.Info(\"hello world!\")\n}\n```\n\n## Standard log handler\n\nLogging via standard logger is handled by default. This is meant for cases where the logging via the standard library is\noutside your control; a library used in your project for example. Those will be logged at `Info` level, but this\nbehaviour can be customised using [`WithStdlogSorter`](https://pkg.go.dev/github.com/codemedic/go-log#WithStdlogSorter).\n\n#### Example\n\n```go\npackage main\n\nimport (\n  \"bytes\"\n  golog \"github.com/codemedic/go-log\"\n)\n\nfunc sortStdlog(b []byte) golog.Level {\n  switch {\n  case bytes.HasPrefix(b, []byte(\"WARNING\")):\n    fallthrough\n  case bytes.HasPrefix(b, []byte(\"ERROR\")):\n    return golog.Warning\n  case bytes.HasPrefix(b, []byte(\"DEBUG\")):\n    return golog.Disabled\n  default:\n    return golog.Info\n  }\n}\n\nfunc main() {\n  l, _ := golog.NewSyslog(golog.WithStdlogSorter(sortStdlog))\n  defer l.Close()\n\n  l.Info(\"hello world!\")\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemedic%2Fgo-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemedic%2Fgo-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemedic%2Fgo-log/lists"}