mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 06:27:38 +00:00
fix: color logs and notification
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
+33
-9
@@ -10,7 +10,7 @@ const prettyJson = format.printf(info => {
|
||||
info.message = JSON.stringify(info.message, null, 4);
|
||||
}
|
||||
|
||||
return `[${timestamp}] ${info.level} :: ${info.message}`;
|
||||
return colors.grey(`[${timestamp}]`) + ` ${info.level} ` + colors.grey('::') + ` ${info.message}`;
|
||||
});
|
||||
|
||||
export const Logger = winston.createLogger({
|
||||
@@ -26,16 +26,40 @@ export const Logger = winston.createLogger({
|
||||
});
|
||||
|
||||
export const Print = {
|
||||
captcha(link: Link, store: Store): string {
|
||||
return colors.cyan(`✖ [${store.name}]`) + colors.grey(` [${link.brand} (${link.series})] ${link.model}`) + colors.yellow(' :: CAPTCHA');
|
||||
captcha(link: Link, store: Store, color?: boolean): string {
|
||||
if (color) {
|
||||
return '✖ ' + buildProductString(link, store, true) + ' :: ' + colors.yellow('CAPTCHA');
|
||||
}
|
||||
|
||||
return `✖ ${buildProductString(link, store)} :: CAPTCHA`;
|
||||
},
|
||||
inStock(link: Link, store: Store): string {
|
||||
return colors.cyan(`✖ [${store.name}]`) + colors.grey(` [${link.brand} (${link.series})] ${link.model}`) + colors.green.bold(' :: IN STOCK 🚨🚀');
|
||||
inStock(link: Link, store: Store, color?: boolean): string {
|
||||
if (color) {
|
||||
return colors.rainbow(`🚀🚨 ${buildProductString(link, store, true)} :: IN STOCK 🚨🚀`);
|
||||
}
|
||||
|
||||
return `🚀🚨 ${buildProductString(link, store)} :: IN STOCK 🚨🚀`;
|
||||
},
|
||||
outOfStock(link: Link, store: Store): string {
|
||||
return colors.cyan(`✖ [${store.name}]`) + colors.grey(` [${link.brand} (${link.series})] ${link.model}`) + colors.red(' :: OUT OF STOCK');
|
||||
outOfStock(link: Link, store: Store, color?: boolean): string {
|
||||
if (color) {
|
||||
return '✖ ' + buildProductString(link, store, true) + ' :: ' + colors.red('OUT OF STOCK');
|
||||
}
|
||||
|
||||
return `✖ ${buildProductString(link, store)} :: OUT OF STOCK`;
|
||||
},
|
||||
rateLimit(link: Link, store: Store): string {
|
||||
return colors.cyan(`✖ [${store.name}]`) + colors.grey(` [${link.brand} (${link.series})] ${link.model}`) + colors.yellow(' :: RATE LIMIT EXCEEDED');
|
||||
rateLimit(link: Link, store: Store, color?: boolean): string {
|
||||
if (color) {
|
||||
return '✖ ' + buildProductString(link, store, true) + ' :: ' + colors.yellow('RATE LIMIT EXCEEDED');
|
||||
}
|
||||
|
||||
return `✖ ${buildProductString(link, store)} :: RATE LIMIT EXCEEDED`;
|
||||
}
|
||||
};
|
||||
|
||||
function buildProductString(link: Link, store: Store, color?: boolean): string {
|
||||
if (color) {
|
||||
return colors.cyan(`[${store.name}]`) + colors.grey(` [${link.brand} (${link.series})] ${link.model}`);
|
||||
}
|
||||
|
||||
return `[${store.name}] [${link.brand} (${link.series})] ${link.model}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user