forked from samc621/SneakerBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
samuelc621
committed
Feb 6, 2021
1 parent
06c26dc
commit d0f7b7d
Showing
12 changed files
with
342 additions
and
64 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
logs | ||
package-lock.json | ||
.env* | ||
!.env.example | ||
|
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,3 +1,4 @@ | ||
node_modules | ||
.env* | ||
!.env.example | ||
!.env.example | ||
logs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const winston = require('winston'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const { format } = winston; | ||
|
||
class Logger { | ||
constructor() { | ||
this.logDir = path.resolve('logs'); | ||
} | ||
|
||
startTaskLogger(taskId) { | ||
if (!fs.existsSync(this.logDir)) { | ||
fs.mkdirSync(this.logDir); | ||
} | ||
|
||
return winston.createLogger({ | ||
transports: [ | ||
new winston.transports.Console(), | ||
new winston.transports.File({ filename: path.join(this.logDir, `/${Date.now()}-taskId=${taskId}.log`) }) | ||
], | ||
format: format.combine( | ||
format.errors({ stack: true }), | ||
format.printf((info) => { | ||
return info.level === 'info' | ||
? `[${new Date().toLocaleString()}] - ${info.message}` | ||
: `[${new Date().toLocaleString()}] - ${info.stack}`; | ||
}) | ||
) | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Logger; |
Oops, something went wrong.