From b10824bb5769c4abb93e3451673b88efdfb9d467 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 14 Sep 2018 14:33:49 +1200 Subject: Log using slf4j and java logging --- src/org/traccar/notification/NotificationFormatter.java | 7 +++++-- src/org/traccar/notification/NotificatorManager.java | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/notification') diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index c011403c5..57be29b31 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -26,8 +26,9 @@ import org.apache.velocity.VelocityContext; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.tools.generic.DateTool; import org.apache.velocity.tools.generic.NumberTool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.traccar.Context; -import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.Event; import org.traccar.model.Position; @@ -36,6 +37,8 @@ import org.traccar.reports.ReportUtils; public final class NotificationFormatter { + private static final Logger LOGGER = LoggerFactory.getLogger(NotificationFormatter.class); + private NotificationFormatter() { } @@ -81,7 +84,7 @@ public final class NotificationFormatter { templateFilePath = Paths.get(path, event.getType() + ".vm").toString(); template = Context.getVelocityEngine().getTemplate(templateFilePath, StandardCharsets.UTF_8.name()); } catch (ResourceNotFoundException error) { - Log.warning(error); + LOGGER.warn(null, error); templateFilePath = Paths.get(path, "unknown.vm").toString(); template = Context.getVelocityEngine().getTemplate(templateFilePath, StandardCharsets.UTF_8.name()); } diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java index a3b13ef25..7e8a9dd0e 100644 --- a/src/org/traccar/notification/NotificatorManager.java +++ b/src/org/traccar/notification/NotificatorManager.java @@ -21,14 +21,17 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.traccar.Context; -import org.traccar.helper.Log; import org.traccar.model.Typed; import org.traccar.notificators.NotificatorNull; import org.traccar.notificators.Notificator; public final class NotificatorManager { + private static final Logger LOGGER = LoggerFactory.getLogger(NotificatorManager.class); + private static final String DEFAULT_WEB_NOTIFICATOR = "org.traccar.notificators.NotificatorWeb"; private static final String DEFAULT_MAIL_NOTIFICATOR = "org.traccar.notificators.NotificatorMail"; private static final String DEFAULT_SMS_NOTIFICATOR = "org.traccar.notificators.NotificatorSms"; @@ -58,7 +61,7 @@ public final class NotificatorManager { try { notificators.put(type, (Notificator) Class.forName(className).newInstance()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - Log.error("Unable to load notificator class for " + type + " " + className + " " + e.getMessage()); + LOGGER.warn("Unable to load notificator class for " + type + " " + className + " " + e.getMessage()); } } } @@ -66,7 +69,7 @@ public final class NotificatorManager { public Notificator getNotificator(String type) { final Notificator notificator = notificators.get(type); if (notificator == null) { - Log.error("No notificator configured for type : " + type); + LOGGER.warn("No notificator configured for type : " + type); return NULL_NOTIFICATOR; } return notificator; -- cgit v1.2.3