{"id":21690671,"url":"https://github.com/reiver/go-log","last_synced_at":"2025-03-20T12:57:27.939Z","repository":{"id":57709430,"uuid":"43999590","full_name":"reiver/go-log","owner":"reiver","description":"A library that provides structured and formatted logging for the Go programming language.","archived":false,"fork":false,"pushed_at":"2025-01-12T07:39:52.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T13:08:12.937Z","etag":null,"topics":["logger","logging","logging-library"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/reiver/go-log","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/reiver.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":"2015-10-10T07:23:10.000Z","updated_at":"2025-01-12T07:39:55.000Z","dependencies_parsed_at":"2022-09-12T22:40:35.776Z","dependency_job_id":null,"html_url":"https://github.com/reiver/go-log","commit_stats":null,"previous_names":["reiver/go-flog"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reiver","download_url":"https://codeload.github.com/reiver/go-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244618428,"owners_count":20482316,"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":["logger","logging","logging-library"],"created_at":"2024-11-25T17:32:54.134Z","updated_at":"2025-03-20T12:57:27.918Z","avatar_url":"https://github.com/reiver.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-log\n\nA library that provides structured and formatted logging for the Go programming language.\n\n(This Go package was originally named `flog`, but in version 2 was renamed to `log`.)\n\n## Online Documention\n\nOnline documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-log\n\n[![GoDoc](https://godoc.org/github.com/reiver/go-log?status.svg)](https://godoc.org/github.com/reiver/go-log)\n\n## Basic Usage\n\nBasic usage of this logger looks like this:\n\n```golang\nrouter := log.NewPrettyWritingRouter(os.Stdout)\n\nlogger := log.New(router)\n```\nOnce you have the logger, you can do things such as:\n\n```golang\nlogger.Print(\"Hello world!\")\nlogger.Println(\"Hello world!\")\nlogger.Printf(\"Hello %s!\", name)\n\nlogger.Panic(\"Uh oh!\")\nlogger.Panicln(\"Uh oh!\")\nlogger.Panicf(\"Uh oh, had a problem happen: %s.\", problemDescription)\n\nlogger.Fatal(\"Something really bad happened!\")\nlogger.Fatalln(\"Something really bad happened!\")\nlogger.Fatalf(\"Something really bad happened: %s.\", problemDescription)\n```\n\nBTW, if the PrettyWritingRouter was being used, then this:\n\n```golang\nlogger.Print(\"Hello world!\")\n```\n\nWould generate output like the following:\n\n```\nHello world!\t(2015-10-10 17:28:49.397356044 -0700 PDT)\n```\n\n(Although note that in actual usage this would have color.)\n\n(Note that for for other routers the actual output would look very different!\nWhat the output looks like is router dependent.)\n\n## Structured Logging\n\nBut those method calls all generated unstructure data.\n\nTo include structured data the logger's With method needs to be used.\nFor example:\n\n```golang\nnewLogger := logger.With(map[string]interface{}{\n\t\"method\":\"Toil\",\n\t\"secret_note\":\"Hi there! How are you?\",\n})\n```\n\nThen if the PrettyWritingRouter was being used, then this:\n\n```golang\nnewLogger.Print(\"Hello world!\")\n```\n\nWould generate output like the following:\n\n```\nHello world!\t(2015-10-10 17:28:49.397356044 -0700 PDT)\tmethod=\"Toil\"\tsecret_note=\"Hi there! How are you?\"\n```\n\n(Again, note that in actual usage this would have color.)\n\n## Deployment Environment\n\nOf course in a real application system you should (probably) create a different kind\nof logger for each deployment environment.\n\nEven though the PrettyWritingRouter is great for a development deployment environment\n(i.e., \"DEV\") it is probably not appropriate for a production deployment environment\n(i.e., \"PROD\").\n\nFor example:\n```golang\nvar logger log.Logger\n\nswitch deploymentEnvironment {\ncase \"DEV\":\n\trouter := log.NewPrettyWritingRouter(os.Stdout)\n\t\n\tlogger = log.New(router)\ncase \"PROD\":\n\tverboseRouter = log.NewDiscardingRouter()\n\tif isVerboseMode {\n\t\tverboseRouter = NewCustomVerboseRouter()\n\t}\n\t\n\tpanicDetectionRouter := log.NewFilteringRouter(NewCustomerPanicRecordingRouter(), filterOnlyPanicsFunc)\n\t\n\terrorDetectionRouter := log.NewFilteringRouter(NewCustomerPanicRecordingRouter(), filterOnlyErrorsFunc)\n\t\n\trouter := NewFanoutRouter(verboseRouter, panicDetectionRouter, errorDetectionRouter)\n\t\n\tlogger = log.New(router)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiver%2Fgo-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freiver%2Fgo-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiver%2Fgo-log/lists"}