-
-
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.
* Added type declaration for .eslintrc.mjs.
* Isolated logging code into LogFactory.mts. * Moved build scripts to "build" directory. * Fixed unit-tests.
- Loading branch information
Showing
12 changed files
with
256 additions
and
260 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {Linter} from "eslint"; | ||
|
||
declare const config: Linter.Config; | ||
export default config; |
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,49 @@ | ||
import { | ||
createLogger, | ||
format, | ||
Logger, | ||
transports | ||
} from "winston"; | ||
|
||
// https://stackoverflow.com/a/63486530/14731 | ||
const Reset = "\x1b[0m"; | ||
const FgWhite = "\x1b[37m"; | ||
const BgRed = "\x1b[41m"; | ||
|
||
class LogFactory | ||
{ | ||
/** | ||
* @param name the name of the logger | ||
*/ | ||
public static getLogger(name: string): Logger | ||
{ | ||
return createLogger({ | ||
transports: [new transports.Console()], | ||
format: format.combine( | ||
format(info => | ||
{ | ||
// https://github.com/winstonjs/winston/issues/1345#issuecomment-393853665 | ||
info.level = info.level.toUpperCase(); | ||
return info; | ||
})(), | ||
format.errors({stack: true}), | ||
format.prettyPrint(), | ||
format.colorize(), | ||
format.timestamp({format: "YYYY-MM-DD HH:mm:ss.SSS"}), | ||
format.printf(({ | ||
timestamp, | ||
level, | ||
message, | ||
stack | ||
}) => | ||
{ | ||
if (stack) | ||
return `${timestamp} ${level} ${FgWhite + BgRed + name + Reset} - ${message}\n${stack}`; | ||
return `${timestamp} ${level} ${FgWhite + BgRed + name + Reset} - ${message}`; | ||
}) | ||
) | ||
}); | ||
} | ||
} | ||
|
||
export {LogFactory}; |
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
File renamed without changes.
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.