jclarke0000 / MMM-OpenWeatherForecast

Magic Mirror weather module using OpenWeather API
42 stars 25 forks source link

Feature: Provide logging when incorrectly configured #4

Closed jokajak closed 3 years ago

jokajak commented 3 years ago

Simple PEBKAC request, I used lat and lon instead of latitude and longitude and wondered why it wasn't working. It would be nice if an error message was logged when required configuration values are missing.

Nice work!

jclarke0000 commented 3 years ago

This logging already exists. If you're using PM2, you'll see it when you run pm2 logs mm. Otherwise if you're running it from the command line, you see such errors there.

Specific code is in node_help.js, lines 37-41:

      if (payload.apikey == null || payload.apikey == "") {
        console.log( "[MMM-OpenWeatherForecast] " + moment().format("D-MMM-YY HH:mm") + " ** ERROR ** No API key configured. Get an API key at https://darksky.net" );
      } else if (payload.latitude == null || payload.latitude == "" || payload.longitude == null || payload.longitude == "") {
        console.log( "[MMM-OpenWeatherForecast] " + moment().format("D-MMM-YY HH:mm") + " ** ERROR ** Latitude and/or longitude not provided." );
      } else {