{"id":22422126,"url":"https://github.com/abumq/easyloggingpp-node","last_synced_at":"2025-08-01T06:31:01.555Z","repository":{"id":57218909,"uuid":"127199986","full_name":"abumq/easyloggingpp-node","owner":"abumq","description":"Simple and efficient logging library for Node.js","archived":false,"fork":false,"pushed_at":"2019-10-25T08:41:17.000Z","size":470,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-24T17:14:06.170Z","etag":null,"topics":["easyloggingpp","js-library","logging-library","native-bindings","node-logger","nodejs"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abumq.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}},"created_at":"2018-03-28T21:21:41.000Z","updated_at":"2023-06-03T07:22:31.000Z","dependencies_parsed_at":"2022-08-29T02:11:48.979Z","dependency_job_id":null,"html_url":"https://github.com/abumq/easyloggingpp-node","commit_stats":null,"previous_names":["abumq/easyloggingpp-node","amrayn/easyloggingpp-node","zuhd-org/easyloggingpp-node"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abumq%2Feasyloggingpp-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abumq%2Feasyloggingpp-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abumq%2Feasyloggingpp-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abumq%2Feasyloggingpp-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abumq","download_url":"https://codeload.github.com/abumq/easyloggingpp-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228339317,"owners_count":17904513,"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":["easyloggingpp","js-library","logging-library","native-bindings","node-logger","nodejs"],"created_at":"2024-12-05T17:11:47.757Z","updated_at":"2024-12-05T17:11:48.994Z","avatar_url":"https://github.com/abumq.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"﷽\n\n# Easylogging++ Node.js Binding\n\n[![Build Status](https://img.shields.io/travis/amrayn/easyloggingpp-node/master.svg)](https://travis-ci.org/muflihun/easyloggingpp-node/branches)\n[![Build status](https://ci.appveyor.com/api/projects/status/sfcgrehu8ypkrun3?svg=true)](https://ci.appveyor.com/project/abumusamq/easyloggingpp-node)\n\n[![Version](https://img.shields.io/npm/v/easyloggingpp.svg)](https://www.npmjs.com/package/easyloggingpp)\n\n[![GitHub license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/amrayn/easyloggingpp-node/blob/master/LICENSE)\n\n[![Donate](https://amrayn.github.io/donate.png?v2)](https://amrayn.com/donate)\n\nEasylogging++ Node.js binding provides ability to use efficient [Easylogging++](https://github.com/amrayn/easyloggingpp) to log important logs for your application.\n\n## Requirements\n\n * Node 7+\n\n## Download\n```\nnpm install --save easyloggingpp\n```\n\n## Getting Started\n```js\nconst easyloggingpp = require('easyloggingpp');\nconst ConfigType = easyloggingpp.ConfigType;\nconst Level = easyloggingpp.Level;\nconst logger = easyloggingpp.getLogger('mylogger'); // register logger\n\neasyloggingpp.configureAllLoggers([\n    {\n        config: ConfigType.Format,\n        value: '%levshort %datetime %fbase:%line %msg',  // \u003c-- fbase or file for full path\n    },\n    {\n        config: ConfigType.Filename,\n        value: 'logs/output.log'\n    }\n]);\n\n// alternatively you can use following to set default configurations\n// for future loggers as well as existing logger\neasyloggingpp.configureAllLoggers({\n    config_file: 'easylogging-config.conf',\n});\n\nlogger.info('simple log');\nlogger.info('array %s', [1, 2, 3]);\nvar person = { 'name': 'Adam', 'age': 960, }\nlogger.info('obj %s', person);\n\nlogger.error('an error occurred %s', new Error(\"error msg\"));\n\neasyloggingpp.setLogErrorStack(false); // turn stack logging off\nlogger.fatal('serious error occurred %s', new Error(\"fatal msg\"));\nlogger.error('an error occurred %s', new Error(\"error msg\"));\n```\n\nAbove will print something like:\n![sample-output]\n\n## Log\n```js\nlogger.info(...);\nlogger.warn(...);\nlogger.error(...);\nlogger.debug(...);\nlogger.trace(...);\nlogger.fatal(...);\nlogger.verbose(verbose_level, ...);\n```\n\n## Log Formats\nYou can use advanced logging format specifiers.\n\n```\nlogger.info('array %s', [1, 2, 3]);\n```\n\nTaken from [utils.format](https://nodejs.org/docs/latest/api/util.html#util_util_format_format_args)\n\n| Format specifier | Explanation |\n|----|-----|\n| %s | String. |\n| %d | Number (integer or floating point value). |\n| %i | Integer. |\n| %f | Floating point value. |\n| %j | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |\n| %% | single percent sign ('%'). This does not consume an argument. |\n\n`%o` and `%O` should not be used. Use `%s` instead for better output.\n\n## Global Configuration\n### [via File](https://github.com/amrayn/easyloggingpp#using-configuration-file)\n```js\neasyloggingpp.configureAllLoggers({\n    config_file: 'easylogging-config.conf',\n});\n```\n\nThis will configure all the existing loggers and set this new configuation to default for future loggers.\n\n### All Levels\n```js\neasyloggingpp.configureAllLoggers({\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %msg',\n});\n```\n**or using array**\n```js\neasyloggingpp.configureAllLoggers([\n  {\n      config: easyloggingpp.ConfigType.Format,\n      value: '%datetime %msg',\n  },\n  {\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %file:%line %msg',\n  }\n]);\n```\n\nThis will configure existing loggers but will not change future loggers.\n\n### Specific Level\n```js\neasyloggingpp.configureAllLoggers({\n    level: easyloggingpp.Level.Info,\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %msg',\n});\n```\n**or using array**\n```js\neasyloggingpp.configureAllLoggers([\n  {\n      level: easyloggingpp.Level.Info,\n      config: easyloggingpp.ConfigType.Format,\n      value: '%datetime %msg',\n  },\n  {\n    level: easyloggingpp.Level.Debug,\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %file:%line %msg',\n  }\n]);\n```\nThis will configure existing loggers but will not change future loggers.\n\n## Logger Configuration\n### [via File](https://github.com/amrayn/easyloggingpp#using-configuration-file)\n```js\nconst logger = easyloggingpp.getLogger('logger1');\nlogger.configure({\n    config_file: 'easylogging-config.conf',\n});\n```\n\n### All Levels\n```js\nconst logger = easyloggingpp.getLogger('logger1');\n\nlogger.configure({\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %msg',\n});\n```\n**or using array**\n```js\nconst logger = easyloggingpp.getLogger('logger1');\nlogger.configure({\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %msg',\n});\n```\n\n### Specific Level\n```js\nconst logger = easyloggingpp.getLogger('logger1');\n\nlogger.configure({\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %msg',\n});\n```\n**or using array**\n```js\nconst logger = easyloggingpp.getLogger('logger1');\nlogger.configure({\n    config: easyloggingpp.ConfigType.Format,\n    value: '%datetime %msg',\n});\n```\n\nThis will configure existing loggers but will not change future loggers.\n\n## Add/Remove [Logging Flag](https://github.com/amrayn/easyloggingpp#logging-flags)\n```js\neasyloggingpp.addFlag(easyloggingpp.LoggingFlag.ColoredTerminalOutput);\neasyloggingpp.removeFlag(easyloggingpp.LoggingFlag.ColoredTerminalOutput);\n```\n\n\n## Profiler\nYou can use built-in profiler\n```js\nlogger.startProfiling('profiling-id');\n// some heavy task\nfor (var i = 0; i \u003c 100000; ++i) {\n\n}\nlogger.endProfiling('profiling-id');\n\n// other tasks that will not be profiled\n// if needed or you could use finishProfiling directly\n\nlogger.finishProfiling('profiling-id', (item) =\u003e {\n    logger.info(`finished profiling in ${item.diff}ms`);\n});\n```\n\n## Notes\nSome notes for those who have previous experience with Easylogging++ (and for those who are absolutely new)\n\n* Logs are written to `/dev/null` by default. You must configure via `easyloggingpp.configureAllLoggers` at initialization.\n* Loggers are created automatically when you use `easyloggingpp.getLogger`.\n* `ColoredTerminalOutput` flag is set by default. You can unset it using `easyloggingpp.removeFlag`\n* You can safely log with `Fatal` level as `DisableApplicationAbortOnFatalLog` flag is set by default. You should not remove this flag. [Read more](https://github.com/amrayn/easyloggingpp#logging-flags)\n\n## License\n```\nCopyright 2017-present Amrayn Web Services\nCopyright 2017-present @abumusamq\n\nhttps://github.com/amrayn\nhttps://amrayn.com\nhttps://muflihun.com\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n  [sample-output]: https://github.com/amrayn/easyloggingpp-node/raw/master/rc/output.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabumq%2Feasyloggingpp-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabumq%2Feasyloggingpp-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabumq%2Feasyloggingpp-node/lists"}