{"id":16479833,"url":"https://github.com/fredmaggiowski/gonyan","last_synced_at":"2025-02-28T16:17:31.174Z","repository":{"id":123037816,"uuid":"103749751","full_name":"fredmaggiowski/gonyan","owner":"fredmaggiowski","description":"Gonyan is a simple stream based logging library for Go","archived":false,"fork":false,"pushed_at":"2019-10-17T13:00:39.000Z","size":62,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T08:44:53.598Z","etag":null,"topics":["go","log-stream","logger","logging","stream"],"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/fredmaggiowski.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":"2017-09-16T12:16:43.000Z","updated_at":"2019-10-17T13:00:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"033e99df-326b-4950-9556-674d1bdd270f","html_url":"https://github.com/fredmaggiowski/gonyan","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredmaggiowski%2Fgonyan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredmaggiowski%2Fgonyan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredmaggiowski%2Fgonyan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredmaggiowski%2Fgonyan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredmaggiowski","download_url":"https://codeload.github.com/fredmaggiowski/gonyan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241180614,"owners_count":19923251,"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":["go","log-stream","logger","logging","stream"],"created_at":"2024-10-11T12:53:02.424Z","updated_at":"2025-02-28T16:17:31.152Z","avatar_url":"https://github.com/fredmaggiowski.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gonyan\nGonyan is a simple stream based logging library for Go.\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/fredmaggiowski/gonyan)](https://goreportcard.com/report/github.com/fredmaggiowski/gonyan)\u0026nbsp;\n[![Build Status](https://travis-ci.org/fredmaggiowski/gonyan.svg?branch=master)](https://travis-ci.org/fredmaggiowski/gonyan)\u0026nbsp;\n[![GoDoc](https://godoc.org/github.com/fredmaggiowski/gonyan?status.svg)](https://godoc.org/github.com/fredmaggiowski/gonyan)\u0026nbsp;\n[![codecov](https://codecov.io/gh/fredmaggiowski/gonyan/branch/master/graph/badge.svg)](https://codecov.io/gh/fredmaggiowski/gonyan)\u0026nbsp;\n[![GitHub issues](https://img.shields.io/github/issues/fredmaggiowski/gonyan.svg \"GitHub issues\")](https://github.com/fredmaggiowski/gonyan)\n\n\nThe idea behind the package is to allow the creation of a logging utility capable of sending machine readable logs to different targets (called _Streams_) based on the desired logging level.\n\n### Example\n\n\n```go\npackage main\n\nimport (\n  \"os\"\n  \"github.com/fredmaggiowski/gonyan\"\n)\n\nfunc main() {\n  log := gonyan.NewLogger(\"GH-Example\", true)\n\n  log.RegisterStream(gonyan.Fatal, os.Stderr)\n  if verboseMode {\n    log.RegisterStream(gonyan.Debug, os.Stdout)\n  }\n  \n  log.Debug(\"Hello, World!\")\n\n  if err := doSomething(); err != nil {\n    log.Errorf(\"doSomething() failed: %s\", err.Error())\n    return\n  }\n\n  log.Debug(\"doSomething() worked fine\")\n}\n```\nIn this example two streams are registered for two different logging levels: `stdout` for `Debug` level and `stderr` for `Error` level. Log messages sent for the `Debug` level will be streamed only to `stdout` stream while those sent with `Error` level will be streamed only to `stderr` stream.\n\nPlease note that streams are completely optional, you can call all logging functions even without registering any stream, your program won't crash but won't even log anything (of course).\n\nAlso, each logging level can have multiple stream registered and custom streams can be defined and used leaving you the power to decide what log, how, where and when.\n\n## Stream\n\n\u003e Yeah, but what is a stream?\n\nA stream is whatever `struct` that implements the function `Write([]byte) (int, error)` this choice allows Gonyan to natively support many `I/O` structures (e.g. `File`, `bytes.Buffer`, `bufio.Writer`, etc..) and being agnostic regarding where the log will be actually used. \n\nWith time, many streams will be provided out-of-the-box but everyone can create its own custom stream object and transparently provide it to the Gonyan logger.\n \n### Formatting\n\nAs of now log messages are streamed as JSON strings, better support for other/custom formats has to be defined.\n\nExample: \n```\n{\"tag\":\"GH-Example\",\"timestamp\":1515161633123,\"message\":\"Hello, World!\"}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredmaggiowski%2Fgonyan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredmaggiowski%2Fgonyan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredmaggiowski%2Fgonyan/lists"}