Adding debug-log
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package se.urmo.electricityalert.alert;
|
package se.urmo.electricityalert.alert;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -12,10 +13,9 @@ import se.urmo.electricityalert.store.InMemoryPriceStore;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class AlertService {
|
public class AlertService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AlertService.class);
|
|
||||||
|
|
||||||
private final InMemoryPriceStore store;
|
private final InMemoryPriceStore store;
|
||||||
private final TelegramNotifier notifier;
|
private final TelegramNotifier notifier;
|
||||||
private final BigDecimal threshold;
|
private final BigDecimal threshold;
|
||||||
@ -33,7 +33,7 @@ public class AlertService {
|
|||||||
public void checkPrices() {
|
public void checkPrices() {
|
||||||
LocalDateTime oneHourLater = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1);
|
LocalDateTime oneHourLater = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1);
|
||||||
ElectricityPrice price = store.get(oneHourLater);
|
ElectricityPrice price = store.get(oneHourLater);
|
||||||
|
log.debug("Checking price at {} ({})", oneHourLater, price);
|
||||||
if (price != null && price.price().compareTo(threshold) < 0 && !store.alreadyNotified(oneHourLater)) {
|
if (price != null && price.price().compareTo(threshold) < 0 && !store.alreadyNotified(oneHourLater)) {
|
||||||
String msg = String.format("⚡ In the next hour (%s) the price is %.2f SEK/kWh. Plug in the car!",
|
String msg = String.format("⚡ In the next hour (%s) the price is %.2f SEK/kWh. Plug in the car!",
|
||||||
oneHourLater, price.price());
|
oneHourLater, price.price());
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
logging.level.root=DEBUG
|
||||||
# ? Telegram Bot
|
# ? Telegram Bot
|
||||||
telegram.bot.token=${TELEGRAM_BOT_TOKEN}
|
telegram.bot.token=${TELEGRAM_BOT_TOKEN}
|
||||||
telegram.chat.id=${TELEGRAM_CHAT_ID:7321440614}
|
telegram.chat.id=${TELEGRAM_CHAT_ID:7321440614}
|
||||||
|
|||||||
Reference in New Issue
Block a user