chore(misc): normalize logs (#242)

This commit is contained in:
Jef LeCompte
2020-09-23 14:20:06 -04:00
committed by GitHub
parent 8466f9f398
commit 7c50e2b5aa
21 changed files with 239 additions and 183 deletions
+9 -7
View File
@@ -1,5 +1,6 @@
import {Link, Store} from '../store/model';
import {Logger, Print} from '../logger';
import {Config} from '../config';
import {Logger} from '../logger';
import Push from 'pushover-notifications';
const pushover = Config.notifications.pushover;
@@ -8,16 +9,17 @@ const push = new Push({
user: pushover.username
});
export function sendPushoverNotification(cartUrl: string) {
export function sendPushoverNotification(link: Link, store: Store) {
const message = {
message: cartUrl
message: link.cartUrl ? link.cartUrl : link.url,
title: Print.inStock(link, store)
};
push.send(message, (err: Error, result: string) => {
if (err) {
Logger.error(err);
push.send(message, (error: Error) => {
if (error) {
Logger.error('✖ couldn\'t send pushover message', error);
} else {
Logger.info(` pushover notification sent: ${result}`);
Logger.info('✔ pushover message sent');
}
});
}