| 75 | } |
| 76 | |
| 77 | private console(value: any, type: Type) { |
| 78 | const types: Type[] = []; |
| 79 | |
| 80 | this.configService.get<Log>('LOG').LEVEL.forEach((level) => types.push(Type[level])); |
| 81 | |
| 82 | const typeValue = typeof value; |
| 83 | if (types.includes(type)) { |
| 84 | if (configService.get<Log>('LOG').COLOR) { |
| 85 | console.log( |
| 86 | /*Command.UNDERSCORE +*/ Command.BRIGHT + Level[type], |
| 87 | '[Evolution API]', |
| 88 | Command.BRIGHT + Color[type], |
| 89 | this.instance ? `[${this.instance}]` : '', |
| 90 | Command.BRIGHT + Color[type], |
| 91 | `v${packageJson.version}`, |
| 92 | Command.BRIGHT + Color[type], |
| 93 | process.pid.toString(), |
| 94 | Command.RESET, |
| 95 | Command.BRIGHT + Color[type], |
| 96 | '-', |
| 97 | Command.BRIGHT + Color.VERBOSE, |
| 98 | `${formatDateLog(Date.now())} `, |
| 99 | Command.RESET, |
| 100 | Color[type] + Background[type] + Command.BRIGHT, |
| 101 | `${type} ` + Command.RESET, |
| 102 | Color.WARN + Command.BRIGHT, |
| 103 | `[${this.context}]` + Command.RESET, |
| 104 | Color[type] + Command.BRIGHT, |
| 105 | `[${typeValue}]` + Command.RESET, |
| 106 | Color[type], |
| 107 | typeValue !== 'object' ? value : '', |
| 108 | Command.RESET, |
| 109 | ); |
| 110 | typeValue === 'object' ? console.log(/*Level.DARK,*/ value, '\n') : ''; |
| 111 | } else { |
| 112 | console.log( |
| 113 | '[Evolution API]', |
| 114 | this.instance ? `[${this.instance}]` : '', |
| 115 | process.pid.toString(), |
| 116 | '-', |
| 117 | `${formatDateLog(Date.now())} `, |
| 118 | `${type} `, |
| 119 | `[${this.context}]`, |
| 120 | `[${typeValue}]`, |
| 121 | value, |
| 122 | ); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | public log(value: any) { |
| 128 | this.console(value, Type.LOG); |