ci(docs-infra): improve preview-server logging

This commit is contained in:
Pete Bacon Darwin
2018-05-12 15:39:16 +01:00
parent cc6f36a9d7
commit 36c4c8daa9
12 changed files with 62 additions and 100 deletions

View File

@ -73,3 +73,13 @@ export const getEnvVar = (name: string, isOptional = false): string => {
return value || '';
};
export function createLogger(scope: string) {
const padding = ' '.repeat(20 - scope.length);
return {
error: (...args: any[]) => console.error(`[${new Date()}]`, `${scope}:${padding}`, ...args),
info: (...args: any[]) => console.info(`[${new Date()}]`, `${scope}:${padding}`, ...args),
log: (...args: any[]) => console.log(`[${new Date()}]`, `${scope}:${padding}`, ...args),
warn: (...args: any[]) => console.warn(`[${new Date()}]`, `${scope}:${padding}`, ...args),
};
}