-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Remove
winston
, since we only use colored console.log
- Loading branch information
Showing
11 changed files
with
44 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
}, | ||
"dependencies": { | ||
"adm-zip": "^0.5.10", | ||
"dotenv": "^16.0.3", | ||
"winston": "^3.8.2" | ||
"dotenv": "^16.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import winston, { format, transports } from 'winston'; | ||
|
||
import { config } from './config'; | ||
|
||
const { timestamp, label, printf } = format; | ||
const colors = { | ||
error: '\x1b[31m', | ||
info: '\x1b[32m', | ||
debug: '\x1b[34m', | ||
warn: '\x1b[33m', | ||
reset: '\x1b[0m' | ||
}; | ||
|
||
const customFormat = printf(({ level, message, label, timestamp }) => { | ||
return `${timestamp} [${label}] ${level}: ${message}`; | ||
}); | ||
function colorText(status: string, ...anything: any) { | ||
const colorCode = colors[status] || colors.reset; | ||
const timestamp = new Date().toISOString().replace('T', ' '); | ||
console.log( | ||
`${timestamp} [tosu] ${colorCode}${status}${colors.reset}:`, | ||
...anything | ||
); | ||
} | ||
|
||
export const configureLogger = () => | ||
winston.configure({ | ||
level: config.debugLogging ? 'debug' : 'info', | ||
transports: [ | ||
// | ||
// - Write to all logs with specified level to console. | ||
new transports.Console({ | ||
format: format.combine( | ||
format.colorize(), | ||
label({ label: 'tosu' }), | ||
timestamp(), | ||
customFormat | ||
) | ||
}) | ||
] | ||
}); | ||
export const wLogger = { | ||
info: (...args: any) => colorText('info', ...args), | ||
debug: (...args: any) => { | ||
if (config.debugLogging != true) return; | ||
|
||
export const wLogger = winston; | ||
colorText('debug', ...args); | ||
}, | ||
error: (...args: any) => colorText('error', ...args), | ||
warn: (...args: any) => colorText('warn', ...args) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.