Skip to content

Commit

Permalink
fix: Added support to change default lib logger (close #1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Apr 1, 2023
1 parent 8ead812 commit 7157b18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config.ts
Expand Up @@ -27,7 +27,7 @@ export default {
daysToArchive: 45,
},
log: {
level: 'error',
level: 'error', // Before open a issue, change level to silly and retry a action
logger: ['console', 'file'],
},
createOptions: {
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { defaultLogger } from '@wppconnect-team/wppconnect';
import cors from 'cors';
import express, { NextFunction } from 'express';
import boolParser from 'express-query-boolean';
Expand Down Expand Up @@ -42,6 +43,7 @@ export function initServer(serverOptions: any) {
}

serverOptions = mergeDeep({}, config, serverOptions);
defaultLogger.level = serverOptions.log.level;

setMaxListners(serverOptions);

Expand Down Expand Up @@ -110,6 +112,15 @@ export function initServer(serverOptions: any) {
if (serverOptions.startAllSession) startAllSessions(serverOptions, logger);
});

if (config.log.level === 'error' || config.log.level === 'warn') {
console.log(`\x1b[33m ======================================================
Attention:
Your configuration is configured to show only a few logs, before opening an issue,
please set the log to 'silly', copy the log that shows the error and open your issue.
======================================================
`);
}

return {
app,
routes,
Expand Down

0 comments on commit 7157b18

Please sign in to comment.