logger: Add logs logging function

Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
Cameron Diver 2018-10-16 11:24:28 +01:00 committed by Tim Perry
parent f560aa7523
commit c5d4e30e24

View File

@ -11,6 +11,7 @@ class Logger {
success: NodeJS.ReadWriteStream;
warn: NodeJS.ReadWriteStream;
error: NodeJS.ReadWriteStream;
logs: NodeJS.ReadWriteStream;
};
public formatMessage: (name: string, message: string) => string;
@ -23,6 +24,7 @@ class Logger {
logger.addPrefix('success', chalk.green('[Success]'));
logger.addPrefix('warn', chalk.yellow('[Warn]'));
logger.addPrefix('error', chalk.red('[Error]'));
logger.addPrefix('logs', chalk.green('[Logs]'));
this.streams = {
build: logger.createLogStream('build'),
@ -31,6 +33,7 @@ class Logger {
success: logger.createLogStream('success'),
warn: logger.createLogStream('warn'),
error: logger.createLogStream('error'),
logs: logger.createLogStream('logs'),
};
_.forEach(this.streams, function(stream, key) {
@ -65,6 +68,10 @@ class Logger {
logBuild(msg: string) {
return this.streams.build.write(msg + eol);
}
logLogs(msg: string) {
return this.streams.logs.write(msg + eol);
}
}
export = Logger;