{"id":13481303,"url":"https://github.com/fluent/fluent-logger-golang","last_synced_at":"2025-03-27T11:32:08.662Z","repository":{"id":7945666,"uuid":"9339223","full_name":"fluent/fluent-logger-golang","owner":"fluent","description":"A structured logger for Fluentd (Golang)","archived":false,"fork":false,"pushed_at":"2023-09-11T10:25:53.000Z","size":214,"stargazers_count":390,"open_issues_count":22,"forks_count":104,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-04T18:45:46.524Z","etag":null,"topics":["fluentd","fluentd-logger","golang"],"latest_commit_sha":null,"homepage":"http://godoc.org/github.com/fluent/fluent-logger-golang/fluent","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/fluent.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2013-04-10T05:56:04.000Z","updated_at":"2025-02-12T06:36:50.000Z","dependencies_parsed_at":"2024-01-13T15:37:25.770Z","dependency_job_id":"a0f8b7bb-f5df-4f4a-b490-ed96b2b86340","html_url":"https://github.com/fluent/fluent-logger-golang","commit_stats":{"total_commits":197,"total_committers":40,"mean_commits":4.925,"dds":0.6446700507614214,"last_synced_commit":"5538e904aeb515c10a624da620581bdf420d4b8a"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent%2Ffluent-logger-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent%2Ffluent-logger-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent%2Ffluent-logger-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent%2Ffluent-logger-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluent","download_url":"https://codeload.github.com/fluent/fluent-logger-golang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245836316,"owners_count":20680351,"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":["fluentd","fluentd-logger","golang"],"created_at":"2024-07-31T17:00:50.636Z","updated_at":"2025-03-27T11:32:08.366Z","avatar_url":"https://github.com/fluent.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"fluent-logger-golang\n====\n\n[![Build Status](https://github.com/fluent/fluent-logger-golang/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/fluent/fluent-logger-golang/actions)\n[![GoDoc](https://godoc.org/github.com/fluent/fluent-logger-golang/fluent?status.svg)](https://godoc.org/github.com/fluent/fluent-logger-golang/fluent)\n\n## A structured event logger for Fluentd (Golang)\n\n## How to install\n\n```\ngo get github.com/fluent/fluent-logger-golang/fluent\n```\n\n## Usage\n\nInstall the package with `go get` and use `import` to include it in your project.\n\n```\nimport \"github.com/fluent/fluent-logger-golang/fluent\"\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n  \"github.com/fluent/fluent-logger-golang/fluent\"\n  \"fmt\"\n  //\"time\"\n)\n\nfunc main() {\n  logger, err := fluent.New(fluent.Config{})\n  if err != nil {\n    fmt.Println(err)\n  }\n  defer logger.Close()\n  tag := \"myapp.access\"\n  var data = map[string]string{\n    \"foo\":  \"bar\",\n    \"hoge\": \"hoge\",\n  }\n  error := logger.Post(tag, data)\n  // error := logger.PostWithTime(tag, time.Now(), data)\n  if error != nil {\n    panic(error)\n  }\n}\n```\n\n`data` must be a value like `map[string]literal`, `map[string]interface{}`, `struct` or [`msgp.Marshaler`](http://godoc.org/github.com/tinylib/msgp/msgp#Marshaler). Logger refers tags `msg` or `codec` of each fields of structs.\n\n## Setting config values\n\n```go\nf := fluent.New(fluent.Config{FluentPort: 80, FluentHost: \"example.com\"})\n```\n\n### FluentNetwork\n\nSpecify the network protocol. The supported values are:\n\n * \"tcp\" (use `FluentHost` and `FluentPort`)\n * \"tls\" (use`FluentHost` and `FluentPort`)\n * \"unix\" (use `FluentSocketPath`)\n\nThe default is \"tcp\".\n\n### FluentHost\n\nSpecify a hostname or IP address as a string for the destination of the \"tcp\" protocol.\nThe default is \"127.0.0.1\".\n\n### FluentPort\n\nSpecify the TCP port of the destination. The default is 24224.\n\n### FluentSocketPath\n\nSpecify the unix socket path when `FluentNetwork` is \"unix\".\n\n### Timeout\n\nSet the timeout value of `time.Duration` to connect to the destination.\nThe default is 3 seconds.\n\n### WriteTimeout\n\nSets the timeout value of `time.Duration` for Write call of `logger.Post`.\nSince the default is zero value, Write will not time out.\n\n### BufferLimit\n\nSets the number of events buffered on the memory. Records will be stored in memory up to this number. If the buffer is full, the call to record logs will fail.\nThe default is 8192.\n\n### RetryWait\n\nSet the duration of the initial wait for the first retry, in milliseconds. The actual retry wait will be `r * 1.5^(N-1)` (r: this value, N: the number of retries).\nThe default is 500.\n\n### MaxRetry\n\nSets the maximum number of retries. If the number of retries become larger than this value, the write/send operation will fail.\nThe default is 13.\n\n### MaxRetryWait\n\nThe maximum duration of wait between retries, in milliseconds. If the calculated retry wait is larger than this value, the actual retry wait will be this value.\nThe default is 60,000 (60 seconds).\n\n### TagPrefix\n\nSets the prefix string of the tag. Prefix will be appended with a dot `.`, like `ppp.tag` (ppp: the value of this parameter, tag: the tag string specified in a call).\nThe default is blank.\n\n### Async\n\nEnable asynchronous I/O (connect and write) for sending events to Fluentd.\nThe default is false.\n\n### ForceStopAsyncSend\n\nWhen Async is enabled, immediately discard the event queue on close() and return (instead of trying MaxRetry times for each event in the queue before returning)\nThe default is false.\n\n### AsyncResultCallback\n\nWhen Async is enabled, if this is callback is provided, it will be called on every write to Fluentd. The callback function\ntakes two arguments - a `[]byte` of the message that was to be sent and an `error`. If the `error` is not nil this means the \ndelivery of the message was unsuccessful.\n\n### AsyncReconnectInterval\nWhen async is enabled, this option defines the interval (ms) at which the connection\nto the fluentd-address is re-established. This option is useful if the address\nmay resolve to one or more IP addresses, e.g. a Consul service address.\n\n### SubSecondPrecision\n\nEnable time encoding as EventTime, which contains sub-second precision values. The messages encoded with this option can be received only by Fluentd v0.14 or later.\nThe default is false.\n\n### MarshalAsJson\n\nEnable Json data marshaling to send messages using Json format (instead of the standard MessagePack). It is supported by Fluentd `in_forward` plugin.\nThe default is false.\n\n### RequestAck\n\nSets whether to request acknowledgment from Fluentd to increase the reliability\nof the connection. The default is false.\n\n### TlsInsecureSkipVerify\n\nSkip verifying the server certificate. Useful for development and testing. The default is false.\n\n## FAQ\n\n### Does this logger support the features of Fluentd Forward Protocol v1?\n\n\"the features\" includes heartbeat messages (for TCP keepalive), TLS transport and shared key authentication.\n\nThis logger doesn't support those features. Patches are welcome!\n\n### Is it allowed to call `Fluent.Post()` after connection close?\n\nBefore v1.8.0, the Fluent logger silently reopened connections whenever\n`Fluent.Post()` was called.\n\n```go\nlogger, _ := fluent.New(fluent.Config{})\nlogger.Post(tag, data)\nlogger.Close()\nlogger.Post(tag, data)  /* reopen connection */\n```\n\nHowever, this behavior was confusing, in particular when multiple goroutines\nwere involved. Starting v1.8.0, the logger no longer accepts `Fluent.Post()`\nafter `Fluent.Close()`, and instead returns a \"Logger already closed\" error.\n\n## Tests\n```\n\ngo test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent%2Ffluent-logger-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluent%2Ffluent-logger-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent%2Ffluent-logger-golang/lists"}