Implement logger

log-cool is no longer with Misskey
This commit is contained in:
Aya Morisawa 2016-12-29 17:36:03 +09:00
parent b87e6e8044
commit cf446ac53c
4 changed files with 32 additions and 17 deletions

View file

@ -1,4 +1,4 @@
import {logInfo, logDone, logWarn} from 'log-cool';
import { log } from './logger';
import {exec} from 'shelljs';
export default function(): void {
@ -6,7 +6,7 @@ export default function(): void {
checkDependency('npm', 'npm -v', x => x.match(/^(.*)\r?\n$/)[1]);
checkDependency('MongoDB', 'mongo --version', x => x.match(/^MongoDB shell version: (.*)\r?\n$/)[1]);
checkDependency('Redis', 'redis-server --version', x => x.match(/v=([0-9\.]*)/)[1]);
logDone('Successfully checked external dependencies');
log('Info', 'Successfully checked external dependencies');
}
function checkDependency(serviceName: string, command: string, transform: (x: string) => string): void {
@ -16,8 +16,8 @@ function checkDependency(serviceName: string, command: string, transform: (x: st
};
const x = exec(command, { silent: true }) as any;
if (x.code === code.success) {
logInfo(`DEPS: ${serviceName} ${transform(x.stdout)}`);
log('Info', `DEPS: ${serviceName} ${transform(x.stdout)}`);
} else if (x.code === code.notFound) {
logWarn(`Unable to find ${serviceName}`);
log('Warn', `Unable to find ${serviceName}`);
}
}