{"id":24869983,"url":"https://github.com/deepal/node-gelfy","last_synced_at":"2025-10-15T14:31:12.421Z","repository":{"id":34902138,"uuid":"188259499","full_name":"deepal/node-gelfy","owner":"deepal","description":"📜 GELF (Graylog Extended Log Format) Integrations for Node.js Logging Libraries (based on gelf-stream)","archived":false,"fork":false,"pushed_at":"2024-12-05T04:00:10.000Z","size":923,"stargazers_count":5,"open_issues_count":10,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-20T12:54:42.794Z","etag":null,"topics":["bunyan","gelf","graylog","log","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepal.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-05-23T15:20:35.000Z","updated_at":"2022-05-19T14:45:02.000Z","dependencies_parsed_at":"2025-08-18T09:21:21.546Z","dependency_job_id":"c1e55d77-7431-4854-87ea-664104968a9e","html_url":"https://github.com/deepal/node-gelfy","commit_stats":null,"previous_names":["dpjayasekara/node-gelfy"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/deepal/node-gelfy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-gelfy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-gelfy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-gelfy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-gelfy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepal","download_url":"https://codeload.github.com/deepal/node-gelfy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-gelfy/sbom","scorecard":{"id":331925,"data":{"date":"2025-08-11","repo":{"name":"github.com/deepal/node-gelfy","commit":"e95685de05a8883a5fcda8d21d96e35a31dc9984"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"24 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T03:50:01.388Z","repository_id":34902138,"created_at":"2025-08-18T03:50:01.388Z","updated_at":"2025-08-18T03:50:01.388Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279085451,"owners_count":26100017,"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","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bunyan","gelf","graylog","log","nodejs"],"created_at":"2025-02-01T03:36:22.428Z","updated_at":"2025-10-15T14:31:12.093Z","avatar_url":"https://github.com/deepal.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Gelfy\n\n[![Build Status](https://travis-ci.org/deepal/node-gelfy.svg?branch=master)](https://travis-ci.org/deepal/node-gelfy) [![Coverage Status](https://coveralls.io/repos/github/deepal/node-gelfy/badge.svg?branch=master)](https://coveralls.io/github/deepal/node-gelfy?branch=master) [![Version](https://img.shields.io/npm/v/gelfy.svg)](https://www.npmjs.com/package/gelfy)\n\nA customizable library for publishing application logs in GELF format(Graylog Extended Log Format) to Graylog. A modified version of [gelf-stream](https://github.com/mhart/gelf-stream/blob/master/gelf-stream.js) module for reliability and customizability for any logging library which supports writing to object streams. \n\nWhy Gelfy?\n\n- Logs can be directly pushed to a Graylog instance from the Node.js application\n- Can be integrated directly into your logging library (Built-in integration with Bunyan, customizable for any logging library which supports JSON streams/transports)\n- Supports GELF UDP, TCP, and TCP with TLS.\n- Supports objects with circular references\n\n### How does it work?\n\nGelfy is a just a writable stream in [object mode](https://nodejs.org/api/stream.html#stream_object_mode). Whichever objects written into the `gelfy` stream is sent to the configured Graylog instance in GELF format. \n\n## Installation\n\n```\nnpm i gelfy\n```\n\n## Usage\n\n### With Bunyan logger\n\n```js\nconst gelfy = require('gelfy');\nconst bunyan = require('bunyan');\n\n// See 'options' in API section for all available options\nconst options = {\n host: '127.0.0.1'\n}\n\nconst bunyanStream = gelfy.createBunyanStream(options);\nconst logger = bunyan.createLogger({\n    name: 'myapp',\n    streams: [\n        {\n            type: 'raw',\n            stream: bunyanStream\n        }\n    ]\n});\n\nlogger.info('sample message'); // will be sent to graylog server at 127.0.0.1\n```\n\n### Configuration with 'Any other logging library'\n\nGelfy also has a generic object stream which you can plug into any logging library as a transporter/stream.\n\n```js\nconst gelfy = require('gelfy');\n\n// See 'options' in API section for all available options\nconst options = {\n host: '127.0.0.1'\n}\n\nconst yourLogMessage = {\n    msg: 'this is a log message',\n    hostName: 'localhost',\n    timestamp: '2019-05-25T17:45:28.222Z'\n};\n\nconst gelfStream = gelfy.create(options);\n\n/* Function to parse log message as a GELF Payload. \n * See the following docs for GELF Payload specification:\n * http://docs.graylog.org/en/3.0/pages/gelf.html#gelf-payload-specification \n*/\nconst logParser = (log) =\u003e {\n    return {\n        short_message: log.msg,\n        host: log.hostName,\n        time: new Date(log.timestamp)/1000\n    };\n}\n\ngelfStream.middleware(logParser);\n\n// You can now use `gelfStream` as a transporter/output stream for your library.\n```\n\n## API\n\n### gelfy.create([options])\nCreate a raw gelf object stream with provided options. returns a [GELF Stream](#class-gelfstream) instance\n\n##### options.host\n\u003etype: string, default: 127.0.0.1\n\nGraylog Hostname\n\n##### options.port\n\u003etype: number, default: 12201\n\nGraylog GELF input port. The default value for this is 12201 with GELF UDP. Depending on how many inputs are configured in your Graylog server, you might need to explicitly set this value if it is different.\n\n##### options.defaultFields\n\u003etype: Object, default: 127.0.0.1\n\nAn object containing default fields which should be included in all messages.\n\ne.g, \n\n```js\n{\n   \"appName\": \"myapp\",\n   \"environment\": \"development\"\n}\n```\n\n##### options.protocol\n\u003etype: string, default: udp\n\nTransport layer protocol which should be used for GELF. Possible values are `udp`, `tcp` or `tcp-tls`.\n\n##### options.family\n\u003etype: number, default: 4\n\nNumeric value denoting ipv4 or ipv6. Possible values are `4`, `6`. Alternatively, `ipv4` or `ipv6` is also accepted.\n\n\n##### options.tlsCert\n\u003etype: string\n\nClient certificate for TLS. Required only if [protocol](#optionsprotocol) is set to `tcp-tls` and server requires client certificate authentication.\n\n_See more: [https://nodejs.org/api/tls.html#tls_tls_connect_options_callback](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback)_\n\n##### options.tlsKey\n\u003etype: string\n\nClient key for TLS communication. Required only if [protocol](#optionsprotocol) is set to `tcp-tls` and server requires client certificate authentication.\n\n_See more: [https://nodejs.org/api/tls.html#tls_tls_connect_options_callback](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback)_\n\n##### options.tlsCA\n\u003etype: Array\u003cstring\u003e\n\nServer certificate for TLS communication. Required only if [protocol](#optionsprotocol) is set to `tcp-tls` and the server uses a self-signed certificate.\n\n_See more: [https://nodejs.org/api/tls.html#tls_tls_connect_options_callback](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback)_\n\n##### options.middleware\n\u003etype: Array\u003cFunction\u003e\n\nAdd a list of middleware for parsing JSON log messages before writing to the GELF Stream (See [GELF Stream Middleware](#gelf-stream-middleware) section for more details) This is useful in order to convert arbitrary JSON to a GELF Payload. All adapters for log libraries use middleware in order to parse their logs to the GELF format. See the \"**Configuration with 'Any other logging library'**\" section for an example.\n\nThis function can be called multiple times with different middleware functions. If more than one middleware were provided, they will be called sequentially in the order they were defined in the array before writing the log to the GELF Stream.\n\nIt is also possible to add middleware later by calling `GELFStream.prototype.middleware` function on the created gelf stream.\n\n##### options.includeFullMessage\n\n\u003etype: boolean, default: true\n\nSetting this flag to false will NOT include the original JSON log message in `full_message` gelf field as a string. Set this to `false` to improve the performance if your log messages are too large.\n\n### gelfy.createBunyanStream(options)\n\n`gelfy.createBunyanStream` returns a special GELF stream which has built-in middleware for transforming Bunyan JSON log to GELF format. You can use the GELF stream returned by `gelfy.createBunyanStream` as a Bunyan stream directly. See the example [given above](#with-bunyan-logger).\n\nAll `options` are identical to the `gelfy.create` options above.\n\n## class GELFStream\n\nGELFStream is inherited from [Writable Stream](https://nodejs.org/api/stream.html#stream_writable_streams) class. Therefore, it inherits all the functionality of a Writable Stream. In addition to that, it has the following function.\n\n##### GELFStream.prototype.middleware(middlewareFunction: Function)\n\nAdd middleware to for parsing JSON log messages before writing to the GELF Stream. (See [GELF Stream Middleware](#gelf-stream-middleware) section for more details)\n\n`middleware` function can be called multiple times to add multiple middlewares, and they will be invoked sequentially in the order they were added.\n\n## GELF Stream Middleware\n\nGELF Stream Middleware is a function which can process log messages immediately before they were written into the GELF Stream. If you write your own integration with an arbitrary log library, you can define how the log messages are parsed to the GELF format using middleware. \n\nBuilt-in adapters such as Bunyan come with a pre-included middleware which converts a Bunyan JSON log message into a GELF Payload. See [gelfy.createBunyanStream](#gelfycreatebunyanstream) for more details.\n\n```js\nconst gelfy = require('gelfy');\nconst stream = gelfy.create(); // create a GELF stream with default options\n\nconst middleware1 = (log) =\u003e ({\n    short_message: log.msg,\n    host: log.hostName,\n    time: new Date(log.timestamp)/1000\n});\n\nconst middleware2 = (log) =\u003e ({\n    ...log,\n    some_field: 'test'\n});\n\nstream.middleware(middlware1);\nstream.middleware(middleware2);\n\nstream.write({\n    msg: 'test message',\n    hostName: 'myserver',\n    timestamp: '2019-05-25T17:45:28.222Z'\n});\n\n/* above code will write the following to the gelf stream:\n\n{\n    short_message: 'test message',\n    host: 'myserver',\n    time: 1558806328.222,\n    some_field: 'test'\n}\n\n*/\n```\n\n\n## Contributing\n\nYou can contribute by creating new adapters for other log libraries. Currently, only Bunyan integration is built-in. Have a look at [how it is implemented](./src/adapters/bunyan.js).\n\nYou can also contribute by writing unit tests.\n\n### Running Tests\n\nYou can run tests by simply running the command:\n\n```\nnpm test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Fnode-gelfy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepal%2Fnode-gelfy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Fnode-gelfy/lists"}