{"id":25107489,"url":"https://github.com/enigmatis/polaris-logs","last_synced_at":"2025-08-03T16:39:53.593Z","repository":{"id":34024362,"uuid":"159463089","full_name":"Enigmatis/polaris-logs","owner":"Enigmatis","description":"Write logs in the best manner, based on winston, integrated with logstash","archived":false,"fork":false,"pushed_at":"2023-01-06T01:38:53.000Z","size":3239,"stargazers_count":5,"open_issues_count":22,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-10T05:37:25.509Z","etag":null,"topics":["logger","logging","logstash","winston"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Enigmatis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-28T07:41:49.000Z","updated_at":"2021-04-12T12:11:15.000Z","dependencies_parsed_at":"2023-01-15T04:02:43.125Z","dependency_job_id":null,"html_url":"https://github.com/Enigmatis/polaris-logs","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enigmatis%2Fpolaris-logs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enigmatis%2Fpolaris-logs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enigmatis%2Fpolaris-logs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Enigmatis%2Fpolaris-logs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Enigmatis","download_url":"https://codeload.github.com/Enigmatis/polaris-logs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237735119,"owners_count":19357959,"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":["logger","logging","logstash","winston"],"created_at":"2025-02-07T23:48:14.211Z","updated_at":"2025-02-07T23:48:14.903Z","avatar_url":"https://github.com/Enigmatis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Polaris-logo](static/img/polaris-sm.png)\n\n# polaris-logs\n\n[![Build Status](https://travis-ci.com/Enigmatis/polaris-logs.svg?branch=develop)](https://travis-ci.com/Enigmatis/polaris-logs)\n[![NPM version](https://img.shields.io/npm/v/@enigmatis/polaris-logs.svg?style=flat-square)](https://www.npmjs.com/package/@enigmatis/polaris-logs)\n\nWrite your logs easily in a standardized manner!\n\nEver wanted your logs to look pretty, to contain all the data you need in order to monitor your system, and to be written in an extremely easy way? You can now do this, using this library.\n\n### LoggerConfiguration\n\nThrough this interface you should set the following configuration to the `PolarisLogger`:\n\n-   **loggerLevel** (_LoggerLevel_) - The level the logger is listening on, can be one of the following levels: `fatal` /\n    `error` / `warn` / `info` / `debug` / `trace`.\n-   **logstashConfigurations** (_LogstashConfiguration[] - optional_) - Through this property you can set multiple logstash\n    hosts, ports and protocols (**Notice that you can use `TCP`/`UDP` or `DYNAMIC` for each logstash config**).\n    Use `DYNAMIC` to make polaris-logs decide which protocol to use according to the size of the log.\n-   **writeToConsole** (_boolean - optional_) - Determines if the logger should write the logs to the console.\n-   **writeFullMessageToConsole** (_boolean - optional_) - Set this property to `true`, if you decide to write full\n    detailed logs to the console, since only the `timestamp` accompanied by the `log level`, `message` and\n    `throwable` will be written by default.\n-   **customTransports** (_Transport[] - optional_) - Array of custom transports you can provide to the winston logger.\n\n### ApplicationProperties\n\nThis interface represents the application configurable log properties.\n\nThose properties are:\n\n-   id\n-   name\n-   version\n-   environment\n-   component\n\n### PolarisLogProperties\n\nThis interface represents the log properties that will be logged through the `PolarisLogger`.\n\nThose properties are:\n\n-   `throwable`: The throwable object, if an error occurred. _any | Optional_\n-   `elapsedTime`: You can provide an elapsed execution time of the operation. _number | Optional_\n-   `logId`: You can provide a unique log id for each log. _string | Optional_\n-   `customProperties`: You can provide custom properties, and it will be piped to the log. _any | Optional_\n-   `response`: The response sent to the client. _any | Optional_\n-   `messageId`: A unique identifier of the request/operation process. Something like a transaction id of a process. _string | Optional_\n-   `recordId`: A unique identifier of the log(generated automatically). _string | Optional_\n-   `eventKind`: The kind of event that happened. An event id. _string | Optional_\n-   `eventKindDescription`: A description of the event kind that occurred. _EventKindDescription | Optional_\n-   `reality`: You can provide The reality which the operation took place in. _Reality | Optional_\n-   `request`: The request sent by the client. _Request | Optional_\n-   `entity`: You can provide an entity of your query you want to record. Note that in case you log both entity and entities properties, entity will merged into entities and only entities will be logged. _Entity | Optional_\n-   `entities`: You can provide entities of your query you want to record. Note that in case you log both entity and entities properties, entity will merged into entities and only entities will be logged. _Entity[] | Optional_\n-   `upn`: The user identifier that executed the operation. _string | Optional_\n-   `ip`: The ip address of the server that the request came from. _string | Optional_\n-   `host`: The server/container name where the event occurred. _string | Optional_\n-   `groupId`: The attributes that defines the relation between the entities to the event that occurred. _GroupId | Optional_\n\n### PolarisLogger\n\nThis class interacts with the actual winston logger and responsible for logging provided properties.\n\n### Example\n\n```TypeScript\n\nimport {\n    ApplicationProperties,\n    LoggerConfiguration,\n    LoggerLevel,\n    LogstashConfiguration,\n    LogstashProtocol,\n    PolarisLogger,\n} from '@enigmatis/polaris-logs';\n\nconst appProps: ApplicationProperties = {\n    id: 'p0laris-l0gs',\n    name: 'polaris-logs',\n    version: 'v1',\n    environment: 'environment',\n    component: 'component',\n};\n\nconst logstashConf: LogstashConfiguration[] = [\n    {\n        host: '127.0.0.1',\n        port: 3000,\n        protocol: LogstashProtocol.TCP,\n    },\n    {\n        host: '8.8.8.8',\n        port: 6000,\n        protocol: LogstashProtocol.UDP,\n    },\n    {\n        host: '127.0.0.1',\n        port: 3000,\n        protocol: LogstashProtocol.DYNAMIC,\n    }\n];\n\nconst logConf: LoggerConfiguration = {\n    loggerLevel: LoggerLevel.TRACE,\n    logstashConfigurations: logstashConf,\n    writeToConsole: true,\n    writeFullMessageToConsole: true,\n};\n\nconst logger = new PolarisLogger(logConf, appProps);\n\nlogger.fatal('fatal message', { elapsedTime: 500, eventKind: 'foo' });\nlogger.error('error message', { elapsedTime: 15000, throwable: new Error('oops') });\nlogger.warn('warn message');\nlogger.info('info message');\nlogger.debug('debug message');\nlogger.trace('trace message');\n\n```\n\nFor any additional help and requests, feel free to contact us :smile:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenigmatis%2Fpolaris-logs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenigmatis%2Fpolaris-logs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenigmatis%2Fpolaris-logs/lists"}