{"id":32258633,"url":"https://github.com/structured-log/structured-log","last_synced_at":"2025-10-22T19:51:07.307Z","repository":{"id":16953706,"uuid":"19715927","full_name":"structured-log/structured-log","owner":"structured-log","description":"A JavaScript implementation of Serilog's hybrid text/structured logging","archived":false,"fork":false,"pushed_at":"2022-12-07T09:20:48.000Z","size":926,"stargazers_count":147,"open_issues_count":29,"forks_count":29,"subscribers_count":8,"default_branch":"dev","last_synced_at":"2025-09-23T19:42:08.344Z","etag":null,"topics":["logger","logging","serilog","structured-logging"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/structured-log.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":"2014-05-12T21:22:56.000Z","updated_at":"2024-07-05T04:04:17.000Z","dependencies_parsed_at":"2022-07-13T13:51:31.938Z","dependency_job_id":null,"html_url":"https://github.com/structured-log/structured-log","commit_stats":null,"previous_names":["serilog/serilog.js","structured-log/serilog.js"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/structured-log/structured-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/structured-log","download_url":"https://codeload.github.com/structured-log/structured-log/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log/sbom","scorecard":{"id":855719,"data":{"date":"2025-08-11","repo":{"name":"github.com/structured-log/structured-log","commit":"7c05f737316f62f32775b2fd2f0d69fb207978bd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"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":"Code-Review","score":2,"reason":"Found 4/15 approved changesets -- score normalized to 2","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":"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":"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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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 'dev'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"79 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","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-hr2v-3952-633q","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr","Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-f9cm-qmx5-m98h","Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3","Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-xc7v-wxcw-j472","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"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-23T23:51:31.740Z","repository_id":16953706,"created_at":"2025-08-23T23:51:31.740Z","updated_at":"2025-08-23T23:51:31.740Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280503191,"owners_count":26341693,"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-22T02:00:06.515Z","response_time":63,"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":["logger","logging","serilog","structured-logging"],"created_at":"2025-10-22T19:51:05.965Z","updated_at":"2025-10-22T19:51:07.300Z","avatar_url":"https://github.com/structured-log.png","language":"TypeScript","readme":"# structured-log\n\nA structured logging framework for JavaScript, inspired by [Serilog](http://serilog.net/).\n\n[![npm](https://img.shields.io/npm/v/structured-log.svg)](https://www.npmjs.com/package/structured-log)\n[![Bower](https://img.shields.io/bower/v/structured-log.svg)]()\n[![Build Status](https://travis-ci.org/structured-log/structured-log.svg?branch=master)](https://travis-ci.org/structured-log/structured-log)\n\n## Basic Example\n\n```js\nconst structuredLog = require('structured-log');\n\nconst log = structuredLog.configure()\n  .writeTo(new structuredLog.ConsoleSink())\n  .create();\n\nlog.info('Hello {Name}!', 'Greg');\n```\n\nThe above code will print the following to the console:\n\n    [Information] Hello Greg!\n\n## Installation\n\n**structured-log** is distributed through [npm](https://www.npmjs.com/package/structured-log) and [Bower](https://bower.io/). Run the following:\n\n    yarn add structured-log\n\nIf not using Yarn:\n\n    npm i --save structured-log\n\nOr, using Bower:\n\n    bower install structured-log\n\n\u003e Note: **structured-log** embeds a polyfill for `Object.assign`, but you will need to bring your own\n\u003e `Promise` polyfill to use it in an environment that doesn't support Promises natively.\n\n## Configuration\n\nConfiguring **structured-log** is a straightforward process, going through three steps.\nFirst, we initialize a new logging pipeline configuration by calling `configure()`:\n\n```js\nconst log = structuredLog.configure()\n```\n\nThe second step is the main step. Configuration of different\nfilters and targets is done by chaining methods together in a fluent syntax.\nEvents flow through the pipeline from top to bottom, so new filters and\nenrichers can be inserted between the different sinks to build a highly\ncontrollable pipeline.\n\n```js\n  .writeTo(new structuredLog.ConsoleSink())\n  .minLevel.warning()\n  .writeTo(new OtherExampleSink({ url: 'http://example.com' }))\n  .writeTo(...)\n```\n\nThe chain is closed by calling `create()`, which instantiates a new logger\ninstance based on the pipeline configuration.\n\n```js\n  .create();\n\n// The logger is ready for use!\nlog.verbose('Hello structured-log!');\n```\n\n### Log Levels\n\nThere are 6 log levels available by default, in addition to a setting to disable logging completely.\nIn decreasing order of severity (with descriptions borrowed from [Seq](https://github.com/serilog/serilog/wiki/Writing-Log-Events#log-event-levels)):\n\n|Label|Description|Bitfield|\n|---|---|---|\n|`off`|When the minimum level is set to this, nothing will be logged.|0|\n|`fatal`|Critical errors causing complete failure of the application.|1|\n|`error`|Indicates failures within the application or connected systems.|3|\n|`warning`|Indicators of possible issues or service/functionality degradatio.|7|\n|`information`|Events of interest or that have relevance to outside observers.|15|\n|`debug`|Internal control flow and diagnostic state dumps to facilitate pinpointing of recognised problems.|31|\n|`verbose`|Tracing information and debugging minutiae; generally only switched on in unusual situations.|63|\n\nThe log levels can also be represented as bitfields, and each log level also includes any levels of higher severity.\nFor example, `warning` will also allow events of the `error` level through, but block `information`,\n`debug` and `verbose`.\n\nA minimum level can be set anywhere in the pipeline to only allow events matching that level\nlevel or lower to pass further through the pipeline.\n\nThe below examples will all set the minimum level to `warning`:\n\n```js\n  .minLevel.warning()\n// or\n  .minLevel(7)\n// or\n  .minLevel('warning')\n```\n\nThere is no minimum level set by default, but a common choice is `Information`. Note that if a restrictive level is set\nearly in the pipeline, and a more permissive level is set further down, the events that are filtered out by the more\nrestrictive level will never reach the more permissive filter.\n\nThe Logger object contains shorthand methods for logging to each level.\n\n```js\nlog.fatal('Application startup failed due to a missing configuration file');\nlog.error('Could not parse response message');\nlog.warn('Execution time of {time} exceeded budget of {budget}ms', actualTime, budgetTime);\nlog.info('Started a new session');\nlog.debug('Accept-Encoding header value: {acceptEncoding}', response.acceptEncoding);\nlog.verbose('Exiting getUsers()');\n```\n\nYou can also pass an error object as the first argument to any of the logging methods, which will pass it along with\nthe event and allow it to be processed by the pipeline:\n\n```js\ntry {\n  // something that fails here\n } catch (error) {\n   log.error(error, error.message);\n }\n```\n\n#### Dynamically controlling the minimum level\n\nYou can also control the minimum level dynamically using the `DynamicLevelSwitch` class.\nPass an instance to the `minLevel()` function:\n\n```js\nconst dynamicLevelSwitch = new DynamicLevelSwitch();\n\n// ...\n\n  .minLevel(dynamicLevelSwitch)\n```\n\nYou can then call the same shorthand methods as those present on the `minLevel` object (`error()`, `debug()` etc.) to\ndynamically change the minimum level for the subsequent stages in the pipeline.\n\n```js\nlogger.debug('This message will be logged');\ndynamicLevelSwitch.warning();\nlogger.debug('This message won\\'t');\n```\n\n### Sinks\n\nA *sink* is a recipient for log events going through the pipeline, and is generally used to publish events to some\nexternal source such as the developer console, file system or an online service.\n\nTo add a sink as a target for log events in the pipeline, pass an instance to the `writeTo()` function.\n\n```js\n  .writeTo(new ExampleSink())\n```\n\nThe `Logger` object that's created with the `create()` method is also a valid sink,\nso you can pass it to another pipeline.\n\n```js\nconst logger1 = structuredLog.configure()\n  // ...\n  .create();\n\nconst logger2 = structuredLog.configure()\n  .writeTo(logger1)\n  .create();\n```\n\n#### Built-in sinks\n|Name|Description|\n|---|---|\n|[ConsoleSink](#console-sink)|Outputs events through the `console` object in Node or the browser.|\n\n#### 3rd party sinks\n|Name|Description|\n|---|---|\n|[SeqSink](https://github.com/Wedvich/structured-log-seq-sink)|Outputs events to a [Seq](https://getseq.net) server.|\n\n### Filtering\n\nYou can *filter* which events are passed through the pipeline using the `filter()` function. It takes\na single function parameter that will be used to test events going into the filter, and if it returns `true`,\nthe events will be allowed to continue through the pipeline.\n\nThe below example will filter out any log events with template properties, only\nallowing pure text events through to the next pipeline stage.\n\n```js\n  .filter(logEvent =\u003e logEvent.properties.length === 0)\n```\n\nThe predicate should take a log event as its only parameter, and return true or false.\n\n### Enrichment\n\nLog events going through the pipeline can be *enriched* with additional properties\nby using the `enrich()` function.\n\n```js\n  .enrich({\n    'version': 2,\n    'source': 'Client Application'\n  })\n```\n\nYou can also pass a function as the first argument, and return an object with the properties to enrich with.\nThis can be useful to dynamically add properties based on the current context or state of the application.\n\n```js\nconst state = {\n  user: null\n};\n\n// ...\n\n  .enrich(() =\u003e ({ user: state.user.name }))\n```\n\nThe enricher function will receive a copy of the event properties as its first argument, so that you can conditionally mask\nsensitive information from the event. This can be useful when you want to log detailed information in your local console, but not to external sinks further down the pipeline.\n\n```js\nlog.info('Incorrect client secret: {Secret}', secret});\n\n// ...\n\n  .enrich((properties) =\u003e {\n    if (properties.secret) {\n      return {\n        secret: 'MASKED'\n      };\n    }\n  })\n```\n\n\u003e The `properties` argument is a deep clone of the event properties, and cannot be used to manipulate the source object directly (e.g. `delete properties.secret`).\n\n### Errors\n\nErrors in the logger are suppressed by default. To disable suppression, and allow errors to be propagated to\nthe environment, use the `suppressErrors()` function to set suppression to `false`.\n\n```js\n  .suppressErrors(false)\n```\n\nThis setting is global for the pipeline, so if it is called multiple times in the configuration chain, the value of\nthe last call will be used.\n\n\u003e Only errors throw in the logging pipeline will be suppressed.\n\u003e Errors that occur during configuration will always propagate.\n\n### Console Sink\n\nThe `ConsoleSink`, which outputs event to the Node.js or browser console, is provided by default.\nThe following line creates a new instance that can be passed to the logger configuration:\n\n```js\nvar consoleSink = new ConsoleSink({ /* options */ });\n```\n\nThe `options` object is optional, but can be used to modify the functionality of the sink.\nIt supports the following properties:\n\n|Key|Description|Default|\n|---|---|---|\n|`console`|An object with a console interface (providing `log()`, `info()`, etc.) that will be used by the sink when writing output.|`console` global|\n|`includeProperties`|If `true`, the properties of the log event will be written to the console in addition to the message.|`false`|\n|`includeTimestamps`|If `true`, timestamps will be included in the message that is written to the console.|`false`|\n|`restrictedToMinimumLevel`|If set, only events of the specified level or higher will be output to the console.||\n\n### Batched Sink\n\nThe `BatchedSink` allows for batching events periodically and/or by batch size.\n\nIt can either be used as a wrapper around existing sinks:\n\n```js\nvar batchedSink = new BatchedSink(new ConsoleSink(), { /* options */ });\n```\n\nOr, if developing a sink and using ES6 or TypeScript, you can use it as a base class to add batching capabilities:\n\n```js\nclass MySink extends BatchedSink {\n  constructor() {\n    super(null, { /* options */ });\n  }\n\n  // Override emitCore and/or flushCore to add your own sink's behavior\n\n  emitCore(events) {\n    // ...\n  }\n\n  flushCore() {\n    // ...\n\n    return Promise.resolve();\n    // If you don't return a promise,\n    // a resolved promise will be returned for you\n  }\n}\n```\n\nThe `options` object is optional, but can be used to modify the batching thresholds or add durability to the sink.\nIt supports the following properties:\n\n|Key|Description|Default|\n|---|---|---|\n|`durableStore`|An instance implementing the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) interface (such as `localStorage` in the browser, or [node-localstorage](https://github.com/lmaccherone/node-localstorage) for Node.js applications). If this is set, it will be used as an intermediate store for events until they have been successfully flushed through the pipeline.|`null`|\n|`maxSize`|The maximum number of events in a single batch. The sink will be flushed immediately when this limit is hit.|`100`|\n|`period`|The interval for autmoatic flushing of batches, in seconds.|`10`|\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstructured-log%2Fstructured-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstructured-log%2Fstructured-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstructured-log%2Fstructured-log/lists"}