{"id":19653546,"url":"https://github.com/sematext/winston-logsene","last_synced_at":"2025-04-28T17:31:39.588Z","repository":{"id":28647432,"uuid":"32166668","full_name":"sematext/winston-logsene","owner":"sematext","description":"Winston Transport for Logsene","archived":false,"fork":false,"pushed_at":"2023-07-18T21:57:12.000Z","size":1345,"stargazers_count":13,"open_issues_count":3,"forks_count":6,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-10-28T13:57:12.915Z","etag":null,"topics":["devops","devops-tools","javascript","log-management","logging","logs","logshipper","nodejs"],"latest_commit_sha":null,"homepage":"http://sematext.com/logsene","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/sematext.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-13T16:20:51.000Z","updated_at":"2024-09-10T00:38:41.000Z","dependencies_parsed_at":"2024-06-18T18:25:41.098Z","dependency_job_id":"04fad8c0-aa30-49e4-b298-037af4ee6741","html_url":"https://github.com/sematext/winston-logsene","commit_stats":{"total_commits":152,"total_committers":14,"mean_commits":"10.857142857142858","dds":0.6513157894736843,"last_synced_commit":"3d0d41cac571b5fca38b7042b9d5f4d2fec97000"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fwinston-logsene","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fwinston-logsene/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fwinston-logsene/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fwinston-logsene/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sematext","download_url":"https://codeload.github.com/sematext/winston-logsene/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224124775,"owners_count":17259746,"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":["devops","devops-tools","javascript","log-management","logging","logs","logshipper","nodejs"],"created_at":"2024-11-11T15:14:28.519Z","updated_at":"2024-11-11T15:14:29.007Z","avatar_url":"https://github.com/sematext.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://travis-ci.org/sematext/winston-logsene.svg?branch=master)\n\n\nThis is a transport module for the winston logger [winstonjs/winston](https://github.com/winstonjs/winston) for logging with [Sematext Cloud](http://www.sematext.com/logsene).\n\nWinston-Logsene combines the flexibility of using the Winston logging framework with Sematext Cloud (think Hosted Elasticsearch + Kibana).\nCreate your free account and access token [here](https://apps.sematext.com/ui/registration).\n\n## Usage\n\n```js\nconst Logsene = require('winston-logsene')\nconst { createLogger, format, config } = require('winston')\n\nconst logger = createLogger({\n  levels: config.npm.levels,\n  transports: [new Logsene({\n    token: process.env.LOGS_TOKEN,\n    level: 'debug',\n    type: 'test_logs',\n    url: 'https://logsene-receiver.sematext.com/_bulk'\n  })]\n})\n```\n### Options\n\n- __token__ - Create your free account and access token [here](https://apps.sematext.com/ui/registration).\n- __type__ - Type of your logs - please note you can define [Elasticsearch mapping templates in Sematext Cloud](https://sematext.com/blog/custom-elasticsearch-index-templates-in-logsene/)\n- __url__ - Sematext Cloud receiver URL (or URL for Sematext Enterprise / On Premises), defaults to Sematext Cloud (US) receiver `https://logsene-receiver.sematext.com/_bulk`.  To ship logs to Sematext Cloud (EU) in Europe use `https://logsene-receiver.eu.sematext.com/_bulk`\n- __handleExceptions__ - boolean 'true' logs 'uncaught exceptions'\n- __handleErrors__ - boolean 'true' logs 'unhandled errors'\n- __exitOnError__ - if set to 'false' process will not exit after logging the 'uncaught exceptions'\n- __source__ - name of the logging source, by default name of the main node.js module\n- __setSource__ - \"true\" adds \"source\" to the log event (modifies the object!), default false\n- __rewriter__ - similar to rewriters in winston, rewriter allows modifying of __log meta__ but only for the logsene\n  transport. This is a simple function which takes `level, msg, meta` as parameter and returns the new __meta__ array\n- __flushOnExit__ - Handling SIGTERM, SIGQT, SIGINT and 'beforeExit' to flush logs and terminate. Default value: true.\n\n\n### Examples\n\n```js\nvar Logsene = require('winston-logsene')\nconst { createLogger, format, config } = require('winston')\n\n// example for custom rewriter, e.g. add myServerIp field to all logs\nvar myServerIp = '10.0.0.12'\n\nvar logger = createLogger({\n  levels: config.npm.levels,\n  transports: [new Logsene({\n    // set log level, defaut is 'info'\n    level: 'debug',\n    // optional set a format function\n    format: format.splat(),\n    token: process.env.LOGS_TOKEN,\n    rewriter: function (level, msg, meta) {\n      meta.ip = myServerIp\n      return meta\n    }\n  })]\n})\n\nlogger.info('debug', 'Info Message')\n// use dynamic list of placeholders and parameters for format.splat(), and any Object as Metadata\nlogger.info('Info message no. %d logged to %s', 1, 'Sematext Cloud', {meta: 'test-log', count: 1, tags: ['test', 'info', 'winston']})\n// message placeholders work the same way as in util.format()\n// utilize tags (in the metadata object) as filter to be used in Sematext Cloud user interface\nlogger.info('Info Message', {tags: ['info', 'test']})\nlogger.error('Error message no. %d logged to %s', 1, 'Sematext Cloud', {meta: 'test-error', count: 1, tags: ['test', 'error', 'winston']})\nlogger.warn('Warning message no. %d logged to %s', 1, 'Sematext Cloud', {meta: 'test-warning', count: 1, tags: ['test', 'warning', 'winston']})\nlogger.debug('Debug message no. %d logged to %s', 1, 'Sematext Cloud', {meta: 'test-debug', count: 1})\n\n```\n\n### Schema / Mapping definition for Meta-Data\n\nIt is possible to log any JSON Object as meta data, but please note Sematext Cloud stores data in Elasticsearch and therefore you should define an index template, matching your data structure.\nMore about Elasticsearch mapping and templates for Sematext Cloud:\n[https://sematext.com/blog/custom-elasticsearch-index-templates-in-logsene/](https://sematext.com/blog/custom-elasticsearch-index-templates-in-logsene/)\n\nIn addition you should use different types for different meta data structures to avoid type conflicts in Elasticsearch. Include a type name in the meta-data like {type: 'logType1', ...} - this overwrites the \"type\" property, specified in the contstructor.\n```\nlogger.add (logsene, {token: process.env.LOGSENE_TOKEN, type: 'my_logs'})\n// numeric id, log type from constructor\nlogger.info('hello', {id: 1})\n// The next line will cause a type conflict in Elasticsearch/Sematext Cloud, because id was a number before\nlogger.info('hello', {id: 'ID-1'})\n// using a different type, OK no type conflict for the field 'id' in Elasticsearch//Sematext Cloud\n// because we use a different type in the Elasticsearch//Sematext Cloud index\nlogger.info('hello', {type: 'my_type_with_string_ids',{id: 'ID-1'}})\n```\n\n## Security\n\n- HTTPS is enabled by default\n- Environment variables for Proxy servers:\n  - For HTTPS endpoints (default): HTTPS_PROXY / https_proxy\n```\n        export HTTPS_PROXY=https://my-ssl-proxy.example\n        export HTTPS_PROXY=http://my-proxy.example\n```\n  - For HTTP endpoints (e.g. On-Premises): HTTP_PROXY / http_proxy\n```\n        export HTTP_PROXY=http://my-proxy.example\n        export HTTP_PROXY=https://my-ssl-proxy.example\n```\n\n## License\n\nApache 2, see LICENSE file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsematext%2Fwinston-logsene","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsematext%2Fwinston-logsene","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsematext%2Fwinston-logsene/lists"}