-
Notifications
You must be signed in to change notification settings - Fork 983
feat(logging): human-readable console logs and cleaner plugin errors #7293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: newarchitecture
Are you sure you want to change the base?
Changes from all commits
2eb8ee6
fc7f945
d627811
bbe1fd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,7 @@ | |
| "@types/underscore": "^1.13.0", | ||
| "@typescript-eslint/eslint-plugin": "^8.54.0", | ||
| "@typescript-eslint/parser": "^8.54.0", | ||
| "debug": "^4.4.3", | ||
|
||
| "docdash": "^2.0.1", | ||
| "env-cmd": "^10.1.0", | ||
| "eslint": "^8.56.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,6 +191,7 @@ const async: any = require('async'); | |
| const _: any = require('underscore'); | ||
| const crypto: typeof import('crypto') = require('crypto'); | ||
| const BluebirdPromise: any = require('bluebird'); | ||
| const debug: any = require('debug'); | ||
| const log: LogModule = require('../api/utils/log.js'); | ||
| const logDbRead: Logger = log('db:read'); | ||
| const logDbWrite: Logger = log('db:write'); | ||
|
|
@@ -199,6 +200,7 @@ const exec: typeof cp.exec = cp.exec; | |
| const spawn: typeof cp.spawn = cp.spawn; | ||
| const configextender: ConfigExtenderFn = require('../api/configextender'); | ||
|
|
||
| const d = debug('countly:pluginManager'); | ||
|
||
| // ============================================================ | ||
| // INTERNAL INTERFACES (used within this module only) | ||
| // ============================================================ | ||
|
|
@@ -436,9 +438,9 @@ class PluginManager { | |
| } | ||
| } | ||
| catch (ex: any) { | ||
| console.log('Skipping plugin ' + pluginNames[i] + ' as we could not load it because of errors.'); | ||
| console.error(ex.stack); | ||
| console.log('Saving this plugin as disabled in db'); | ||
| const errorLine = (ex.message || '').split('\n')[0]; | ||
| console.log('Skipping plugin ' + pluginNames[i] + ': ' + errorLine); | ||
| d('Plugin %s load error:\n%s', pluginNames[i], ex.stack); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1272,8 +1274,9 @@ class PluginManager { | |
| } | ||
| } | ||
| catch (ex: any) { | ||
| console.log('skipping plugin because of errors:' + pluginNames[i]); | ||
| console.error(ex.stack); | ||
| const errorLine = (ex.message || '').split('\n')[0]; | ||
| console.log('Skipping plugin ' + pluginNames[i] + ': ' + errorLine); | ||
| d('Plugin %s load error:\n%s', pluginNames[i], ex.stack); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this but please dont enable this by default.
This is only good for dev envs, since most of our logs are now json ( the ones that are not will be converted ) They will be human readable for prod using grafana or other tools.
The other issue with pretty is it works with event emitter and since countly has huge number of subloggers (plugins,modules each have their own) This can cause memory leaks and similar issues
ref: pinojs/pino-pretty#387
ref: pinojs/pino#144
Lets keep this but not enable by default, or by default when NODE_ENV === development or similar?