{"id":32263108,"url":"https://github.com/structured-log/structured-log-dev-bower","last_synced_at":"2026-02-22T17:06:15.922Z","repository":{"id":35011516,"uuid":"39108267","full_name":"structured-log/structured-log-dev-bower","owner":"structured-log","description":"Bower package for SerilogJS. The client-side/browser version of Serilog.","archived":false,"fork":false,"pushed_at":"2015-08-13T01:03:04.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-10T07:39:29.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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":"2015-07-15T00:55:57.000Z","updated_at":"2015-07-20T01:29:55.000Z","dependencies_parsed_at":"2022-09-01T08:00:24.464Z","dependency_job_id":null,"html_url":"https://github.com/structured-log/structured-log-dev-bower","commit_stats":null,"previous_names":["codecapers/serilogjs-bower"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/structured-log/structured-log-dev-bower","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log-dev-bower","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log-dev-bower/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log-dev-bower/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log-dev-bower/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/structured-log","download_url":"https://codeload.github.com/structured-log/structured-log-dev-bower/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/structured-log%2Fstructured-log-dev-bower/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29719509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-10-22T20:47:45.409Z","updated_at":"2026-02-22T17:06:15.911Z","avatar_url":"https://github.com/structured-log.png","language":"JavaScript","readme":"#structured-log\n\nA structured logging framework for Javascript. Based on [Serilog](http://serilog.net/).\n\n**WARNING:** structured-log is a work in progress and will change over time.\n\n## Installation\n\n### Server-side ([Node.js](https://nodejs.org/)) via [npm](https://www.npmjs.com/package/structured-log)\n\n  npm install --save structured-log\n\n### Client-side (Web Browser) via [Bower](http://bower.io/search/?q=structured-log)\n\n  bower install --save structured-log\n \n## Basic Setup\n\nThis section describes the most basic *structured-log* configuration for server and client.\n\n### Server-side\n\nIn your NodeJS script:\n\n\tvar structuredLog = require('structured-log');\n\tvar coloredConsoleSink = require('structured-log/colored-console-sink');\n\n\tvar log = structuredLog.configuration()\n    \t.writeTo(coloredConsoleSink())\n\t    .createLogger();\n    \n### Client-side\n\nIn your HTML file:\n\n```\n  \u003cscript type='text/javascript' src='bower_components/structured-log/structured-log.min.js /\u003e\n```\n\nIn your Javascript code:\n\n\tvar log = structuredLog.configuration() \n    \t.writeTo(structuredLog.consoleSink())\n\t    .createLogger();\n  \n### Multiple sinks\n\nSetup of *structured-log* is via a *fluent API* that configures and creates a logger. One example of this is to specify multilple sinks, eg:\n\n\tvar log = structuredLog.configuration() \n\t\t.writeTo(consoleSink)\n\t\t.writeTo(httpSink({ url: '\u003csome-url\u003e' }))\n\t\t.createLogger();\n\n### Writing to another log\n\nA log can easily be piped to another log:\n\n\tvar someOtherLog = structuredLog.configuration()\n\t\t// ... setup ...\n\t\t.createLogger(); \n\n\tvar log = structuredLog.configuration() \n\t\t.writeTo(consoleSink)\n\t\t.writeTo(someOtherLog)\n\t\t.createLogger();\n\n\n## Basic Usage\n\nDebugging:\n\n\tlog.trace('My debug message!');\n\tlog.debug('My debug message!');\n\tlog.verbose('My debug message!');\n \nInformation:\n\n\tlog.info('Something happened in the application...');\n\nInformation alternative:\n\n\tlog('Something happened in the application...');\n\nWarnings:\n  \n\tlog.warn('Some not-fatal error happened...');\n\nErrors:\n\n\tlog.error('Something bad happened...');\n\tlog.error(exceptionOrErrorObject, 'Something bad happend...');\n\n## Structured Logging\n\nAll the logging functions accept a message template and a set of key/value properties that are used to render the template when constring the log message for display. The properties are maintained separately to the template and rendered message which is what makes this a structured logging system.\n\nHere are some examples that have been adapted for Javascript from the [Serilog C# examples](http://serilog.net/):\n \n\tvar position = { Latitude: 25, Longitude: 134 };\n\tvar elapsedMs = 34;\n\t\n\tlog.info(\"Processed {@Position} in {Elapsed:000} ms.\", {\n\t\tPosition: position,\n\t\tElapsed: elapsedMs\n\t});\n\nProperties can also be specified by positional parameters, the same as how it works in Serilog C#: \n\n\tlog.info(\"Processed {@Position} in {Elapsed:000} ms.\", position, elapsedMs);\n\n## Included Sinks\n\nA *sink* is a plugin that is invoked for each *log event*. Usualy a sink defines an *output method* for logs, such as the ability to output to the [console]( https://developer.mozilla.org/en/docs/Web/API/console).  \n\n*structured-log* includes a number of built-in sinks.\n\n### Server-side\n\nAll sinks are imported using the Nodejs *require* function as follows:\n\n\tvar someSink = require('\u003csink-name\u003e');\n\n| Name | Description | Batched/Unbatched |\n| ---- | ----------- | ----------------- |\n| console-sink | Writes formatted log events to the *console* | Unbatched |\n| colored-console-sink | Same as above, but with colors | Unbatched |\n| json-console-sink | Writes structured json to the console for each log event | Unbatched |\n| stream-sink | Writes formatted log events to a Nodejs stream | Unbatched |\n| json-stream-sink | Writes structured json tot he console for each log event | Unbatched |\n| http-sink | Outputs structured json log events via HTTP post |  Batched |\n\n### Client-side\n\n| Name | Description |\n| ---- | ------------- |\n| console-sink | Writes formatted log events to the *console* | Unbatched |\n| json-console-sink | Writes structured json to the console for each log event | Unbatched |\n| http-sink | Outputs structured json log events via HTTP post | Batched |\n\n## Batching\n\nSome of the sinks are batched. Batched sinks process multiple log events at once usually for increased performance or to reduce timing issues (eg HTTP logs being received out of order). \n\n### Configuring Batched Sinks\n\nAll batched sinks (even custom batched sinks) have the same standard configuration options.\n\n\tvar httpSink = require('structured-log-http-sink'); \n\t\n\tvar log = structuredLog.configuration()\n\t\t.writeTo(httpSink({\n\t\t\turl: 'http://somelogreceiver',    // Configuration for the custom sink.\n\t\t\tbatchSize: 1000,          // Flush the queue every 1000 logs.\n\t\t\ttimeDuration: 3000,         // Milliseconds to wait before flushing the queue.            \n\t\t})\n\t\t.createLogger();\n\n*batchSize* specifies the amount of logs to include in a batch. When this number of logs are in the queue the queue will be flushed and processed by the sink.\n\n*timeDuration* specifies the amount of time that will pass before the log queue is flushed. This ensure that the queue is periodically flushed even if not enought logs events have been queued to trigger the *batchSize* flush. \n\nEither of these options can be omitted and be set to default values.\n\n### Flushing Queued Logs\n\nThe queue of batched logs can be flushed at any time by calling the *flush* function.\n\nIf it suits your purpose you can simply call flush:\n\t\n\tlog.flush();\n\nIf you need a callback when the flush has completed you have two options.\n\nThe first option is the standard Javascript-style callback:\n\n\tlog.flush(function (err) {\n\t\tif (err) {\n\t\t\t// An error occurred while flushing.\n\t\t}\n\t\telse {\n\t\t\t// The queue was flushed successfully.\n\t\t}\n\t});\n \nThe second option is to use the promise that is returned by *flush*:\n\n\tlog.flush()\n\t\t.then(function () {\n\t\t\t// The queue was flushed successfully.\n\t\t})\n\t\t.catch(function (err) {\n\t\t\t// An error occurred while flushing.\n\t\t})\n\t\t.done(); // Terminate the promise chain.\n\n## 3rd-party Sinks\n\nA number of additional sinks are available as separate packages.\n\nIf you release your own custom sink for *structured-log* please let us know and we'll add it to the list!  \n\n### Server-side (via npm)\n\n| Name | Description |\n| ---- | ------------- |\n| [email-sink](???) | Outputs formattted log messages via SMTP |\n| [mongodb-sink](???) | Writes structure json log events to the MongoDB database |\n\n### Client-side (via bower)\n\n| Name | Description |\n| ---- | ------------- |\n| [websockets-sink](???) | Outputs formattted log messages via websockets |\n| [socketio-sink](???) | Outputs formattted log messages via [the Socket.IO library](http://socket.io/) |\n\n## Make your own sink\n\nIt is very easy to make your own sink. You first have to decide if the sink should process log events individually or as a batch.\n\nThere are plenty of built-in examples of sinks. So can you can always copy and modify an existing sink.\n\n### Non-batched custom sink\n\nNon-batched sinks process each log event individually:\n\n\tvar myCustomSink = function (options) {\n\t\treturn {\n\t\t\temit: function (logEvent) {\n\t\t\t\t//\n\t\t\t\t// ... your custom log event processing goes here ...\n\t\t\t\t//\n\t\t\t}\n\t\t};\n\t};\n\t\n\tvar customSinkOptions = {\n\t\t// Whatever custom options you need...\n\t};\n\t\n\tvar log = structuredLog.configure()\n\t\t.writeTo(myCustomSink(customSinkOptions))\n\t\t.createLogger();\n\n### As a Nodejs module\n\nMyCustomSink.js:\n\n\tmodule.exports = function (options) {\n\t\treturn {\n\t\t\temit: function (logEvent) {\n\t\t\t\t//\n\t\t\t\t// ... your custom log event processing goes here ...\n\t\t\t\t//\n\t\t\t}\n\t\t};\n\t};\n\nSomewhereElse.js:\n\n\tvar myCustomSink = require('./MyCustomSink');\n\t\n\tvar customSinkOptions = {\n\t\t// Whatever custom options you need...\n\t};\n\t\n\tvar log = structuredLog.configure()\n\t\t.writeTo(myCustomSink(customSinkOptions))\n\t\t.createLogger();\n\n\n### Batched custom sink\n\nBatched sinks process a batch of log events at a time. *structured-log* buffers log events until the log queue is flushed. By simply replacing the *emit* function with *emitBatch* you can convert your sink to work in batched mode, accepting an *array* of log events instead of just a single  log event.\n\n\tvar myCustomSink = function (options) {\n\t\treturn {\n\t\t\temitBatch: function (logEvents) {\n\t\t\t\t//\n\t\t\t\t// ... process the array of log events ...\n\t\t\t\t//\n\t\t\t}\n\t\t};\n\t};\n\n## Advanced Setup\n\nThe *fluent API* has numerous functions to configure your log.\n\n### Log Levels\n\nSet the minimum log level that is output:\n\n\tvar log = structuredLog.configuration()\n\t\t.minimumLevel('WARN')\n\t\t.writeTo(consoleSink())\n\t\t.createLogger();\n\n*minimumLevel* applies to subsequent sinks in the configuration, so you can use it to set a different level for each sink: \n\n\tvar log = structuredLog.configuration()\n\t\t.minimumLevel('VERBOSE')\n\t\t.writeTo(consoleSink())\n\t\t.minimumLevel('INFO')\n\t\t.writeTo(httpSink())\n\t\t.minimumLevel('ERROR')\n\t\t.writeTo(emailSink())\n\t\t.createLogger();\n\n### Filtering\n\nCustom filtering can be applied to include/exclude logging based on a predicate function. \n\n\tvar log = structuredLog.configuration()\n\t\t.filter(function (logEvent) {\n\t\t\treturn someCondition(logEvent);\n\t\t})\n\t\t.writeTo(consoleSink())\n\t\t.createLogger();\n\nThis kind of filtering affects subsequent sinks in the configuration, you can use it in combination with *clearFilter* to provide different filters for different sinks: \n\n\tvar log = structuredLog.configuration()\n\t\t.filter(function (logEvent) {\n\t\t\treturn okForConsole(logEvent);\n\t\t}))\n\t\t.writeTo(consoleSink())\n\t\t.resetFilter()\n\t\t.filter(function (logEvent) {\n\t\t\treturn okForHttp(logEvent);\n\t\t}))\n\t\t.createLogger();\n\nLogs can also be filtered after configuration, this effectively creates a new log with the added filter:\n\n\tvar log2 = log.filter(function (logEvent) {\n\t\t// ... some condition ...\n\t});\n\t\n\tlog2.info(\"This log is filtered by the new criteria!\");   \n\n\n### Enrichment\n\nEnrichment can be used to add key/value properties to all logs output via a particular logger.\n\n\tvar log = structuredLog.configuration()\n\t\t.enrich({\n\t\t\tUserId: getCurUserId(),\n\t\t\tSessionId: getCurSessionId(),\n\t\t})\n\t\t.writeTo(consoleSink())\n\t\t.createLogger();\n\nA function can also be provided that is evaluated at runtime to attach properties to log events in a more dynamic fashion:\n\n\tvar log = structuredLog.configuration()\n\t\t.enrich(function () {\n\t\t\treturn {\n\t\t\t\tUserId: getCurUserId(),\n\t\t\t\tSessionId: getCurSessionId(),\t\t\n\t\t\t};\n\t\t})\n\t\t.writeTo(consoleSink())\n\t\t.createLogger();\n\nAny number of properties can be attached to log messages in this manner. The properties may then be used in the log messages themselves:\n\n\tlog.info(\"Current user {UserId} has done something.\");\n\nAs with other configuration, the *enrich* only affects subsequent sinks.\n\nLogs can also be enriched after configuration, this effectively creates a new log with additional properties:\n\n\tvar log2 = log.enrich({ NewProperty: 'just for log2' };\n\t\n\tlog2.info(\"I've added a new property: {NewProperty}\");   \n\t\n### Tagging\n\nLogs can be tagged with string values. This is useful to filter and categories logs generated by an application:\n\n\tvar log = structuredLog.configuration()\n\t\t.tag(\"authentication-system\")\n\t\t.writeTo(consoleSink())\n\t\t.createLogger();\n\nLogs can also be tagged after configuration, this effectively creates a new log that has the desired tag:\n\t\n\tvar log2 = log.tag('some-new-tag');\n\t\n\tlog2.info(\"This log is tagged with 'some-new-tag'\");\n\t\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstructured-log%2Fstructured-log-dev-bower","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstructured-log%2Fstructured-log-dev-bower","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstructured-log%2Fstructured-log-dev-bower/lists"}