[logger] Add prefixes to most Log messages (#3923)

Co-authored-by: veeck <gitkraken@veeck.de>
This commit is contained in:
Veeck
2025-10-21 20:32:48 +02:00
committed by GitHub
parent f1c0c38c86
commit a1c1e9560c
34 changed files with 220 additions and 238 deletions

View File

@@ -60,7 +60,7 @@ WeatherProvider.register("envcanada", {
* Called when the weather provider is started
*/
start () {
Log.info(`Weather provider: ${this.providerName} started.`);
Log.info(`[weatherprovider.envcanada] ${this.providerName} started.`);
this.setFetchedLocation(this.config.location);
},
@@ -103,13 +103,13 @@ WeatherProvider.register("envcanada", {
fetchCommon (target) {
const forecastURL = this.getUrl(); // Get the approriate URL for the MSC Datamart Index page
Log.debug(`[weather.envcanada] ${target} Index url: ${forecastURL}`);
Log.debug(`[weatherprovider.envcanada] ${target} Index url: ${forecastURL}`);
this.fetchData(forecastURL, "xml") // Query the Index page URL
.then((indexData) => {
if (!indexData) {
// Did not receive usable new data.
Log.info(`weather.envcanada ${target} - did not receive usable index data`);
Log.info(`[weatherprovider.envcanada] ${target} - did not receive usable index data`);
this.updateAvailable(); // If there were issues, update anyways to reset timer
return;
}
@@ -133,7 +133,7 @@ WeatherProvider.register("envcanada", {
forecastFileURL = forecastURL + forecastFile; // Create full URL to the city's weather data
}
Log.debug(`[weather.envcanada] ${target} Citypage url: ${forecastFileURL}`);
Log.debug(`[weatherprovider.envcanada] ${target} Citypage url: ${forecastFileURL}`);
/*
* If the Citypage filename has not changed since the last Weather refresh, the forecast has not changed and
@@ -141,19 +141,19 @@ WeatherProvider.register("envcanada", {
*/
if (target === "Current" && this.lastCityPageCurrent === forecastFileURL) {
Log.debug(`[weather.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
Log.debug(`[weatherprovider.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
this.updateAvailable(); // Update anyways to reset refresh timer
return;
}
if (target === "Forecast" && this.lastCityPageForecast === forecastFileURL) {
Log.debug(`[weather.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
Log.debug(`[weatherprovider.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
this.updateAvailable(); // Update anyways to reset refresh timer
return;
}
if (target === "Hourly" && this.lastCityPageHourly === forecastFileURL) {
Log.debug(`[weather.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
Log.debug(`[weatherprovider.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
this.updateAvailable(); // Update anyways to reset refresh timer
return;
}
@@ -162,7 +162,7 @@ WeatherProvider.register("envcanada", {
.then((cityData) => {
if (!cityData) {
// Did not receive usable new data.
Log.info(`weather.envcanada ${target} - did not receive usable citypage data`);
Log.info(`[weatherprovider.envcanada] ${target} - did not receive usable citypage data`);
return;
}
@@ -170,7 +170,7 @@ WeatherProvider.register("envcanada", {
* With the city's weather data read, parse the resulting XML document for the appropriate weather data
* elements to create a weather object. Next, set Weather modules details from that object.
*/
Log.debug(`[weather.envcanada] ${target} - Citypage has been read and will be processed for updates`);
Log.debug(`[weatherprovider.envcanada] ${target} - Citypage has been read and will be processed for updates`);
if (target === "Current") {
const currentWeather = this.generateWeatherObjectFromCurrentWeather(cityData);
@@ -191,12 +191,12 @@ WeatherProvider.register("envcanada", {
}
})
.catch(function (cityRequest) {
Log.info(`weather.envcanada ${target} - could not load citypage data from: ${forecastFileURL}`);
Log.info(`[weatherprovider.envcanada] ${target} - could not load citypage data from: ${forecastFileURL}`);
})
.finally(() => this.updateAvailable()); // Update no matter what to reset weather refresh timer
})
.catch(function (indexRequest) {
Log.error(`weather.envcanada ${target} - could not load index data ... `, indexRequest);
Log.error(`[weatherprovider.envcanada] ${target} - could not load index data ... `, indexRequest);
this.updateAvailable(); // If there were issues, update anyways to reset timer
});
},

View File

@@ -155,7 +155,7 @@ WeatherProvider.register("openmeteo", {
this.setCurrentWeather(currentWeather);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openmeteo] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -173,7 +173,7 @@ WeatherProvider.register("openmeteo", {
this.setWeatherForecast(dailyForecast);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openmeteo] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -191,7 +191,7 @@ WeatherProvider.register("openmeteo", {
this.setWeatherHourly(hourlyForecast);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openmeteo] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -217,7 +217,7 @@ WeatherProvider.register("openmeteo", {
this.config.maxEntries = Math.max(1, Math.min(this.config.maxEntries, maxEntriesLimit));
if (!this.config.type) {
Log.error("type not configured and could not resolve it");
Log.error("[weatherprovider.openmeteo] type not configured and could not resolve it");
}
this.fetchLocation();
@@ -340,7 +340,7 @@ WeatherProvider.register("openmeteo", {
this.fetchedLocationName = `${data.city}, ${data.principalSubdivisionCode}`;
})
.catch((request) => {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openmeteo] Could not load data ... ", request);
});
},

View File

@@ -42,7 +42,7 @@ WeatherProvider.register("openweathermap", {
this.setCurrentWeather(currentWeather);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openweathermap] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -64,7 +64,7 @@ WeatherProvider.register("openweathermap", {
this.setFetchedLocation(location);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openweathermap] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -88,7 +88,7 @@ WeatherProvider.register("openweathermap", {
this.setWeatherHourly(weatherData.hours);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.openweathermap] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},

View File

@@ -34,7 +34,7 @@ WeatherProvider.register("pirateweather", {
this.setCurrentWeather(currentWeather);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.pirateweather] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -51,7 +51,7 @@ WeatherProvider.register("pirateweather", {
this.setWeatherForecast(forecast);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.pirateweather] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},

View File

@@ -28,7 +28,7 @@ WeatherProvider.register("smhi", {
this.setFetchedLocation(this.config.location || `(${coordinates.lat},${coordinates.lon})`);
this.setCurrentWeather(weatherObject);
})
.catch((error) => Log.error(`Could not load data: ${error.message}`))
.catch((error) => Log.error(`[weatherprovider.smhi] Could not load data: ${error.message}`))
.finally(() => this.updateAvailable());
},
@@ -43,7 +43,7 @@ WeatherProvider.register("smhi", {
this.setFetchedLocation(this.config.location || `(${coordinates.lat},${coordinates.lon})`);
this.setWeatherForecast(weatherObjects);
})
.catch((error) => Log.error(`Could not load data: ${error.message}`))
.catch((error) => Log.error(`[weatherprovider.smhi] Could not load data: ${error.message}`))
.finally(() => this.updateAvailable());
},
@@ -58,7 +58,7 @@ WeatherProvider.register("smhi", {
this.setFetchedLocation(this.config.location || `(${coordinates.lat},${coordinates.lon})`);
this.setWeatherHourly(weatherObjects);
})
.catch((error) => Log.error(`Could not load data: ${error.message}`))
.catch((error) => Log.error(`[weatherprovider.smhi] Could not load data: ${error.message}`))
.finally(() => this.updateAvailable());
},
@@ -69,7 +69,7 @@ WeatherProvider.register("smhi", {
setConfig (config) {
this.config = config;
if (!config.precipitationValue || ["pmin", "pmean", "pmedian", "pmax"].indexOf(config.precipitationValue) === -1) {
Log.log(`invalid or not set: ${config.precipitationValue}`);
Log.log(`[weatherprovider.smhi] invalid or not set: ${config.precipitationValue}`);
config.precipitationValue = this.defaults.precipitationValue;
}
},

View File

@@ -39,7 +39,7 @@ WeatherProvider.register("ukmetoffice", {
this.setCurrentWeather(currentWeather);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.ukmetoffice] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -63,7 +63,7 @@ WeatherProvider.register("ukmetoffice", {
this.setWeatherForecast(forecast);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.ukmetoffice] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},

View File

@@ -86,8 +86,7 @@ WeatherProvider.register("ukmetofficedatahub", {
* Did not receive usable new data.
* Maybe this needs a better check?
*/
Log.error("Possibly bad current/hourly data?");
Log.error(data);
Log.error("[weatherprovider.ukmetofficedatahub] Possibly bad current/hourly data?", data);
return;
}
@@ -100,7 +99,7 @@ WeatherProvider.register("ukmetofficedatahub", {
})
// Catch any error(s)
.catch((error) => Log.error(`Could not load data: ${error.message}`))
.catch((error) => Log.error(`[weatherprovider.ukmetofficedatahub] Could not load data: ${error.message}`))
// Let the module know there is data available
.finally(() => this.updateAvailable());
@@ -162,8 +161,7 @@ WeatherProvider.register("ukmetofficedatahub", {
* Did not receive usable new data.
* Maybe this needs a better check?
*/
Log.error("Possibly bad forecast data?");
Log.error(data);
Log.error("[weatherprovider.ukmetofficedatahub] Possibly bad forecast data?", data);
return;
}
@@ -176,7 +174,7 @@ WeatherProvider.register("ukmetofficedatahub", {
})
// Catch any error(s)
.catch((error) => Log.error(`Could not load data: ${error.message}`))
.catch((error) => Log.error(`[weatherprovider.ukmetofficedatahub] Could not load data: ${error.message}`))
// Let the module know there is new data available
.finally(() => this.updateAvailable());

View File

@@ -36,7 +36,7 @@ WeatherProvider.register("weatherbit", {
this.setCurrentWeather(currentWeather);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.weatherbit] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -55,7 +55,7 @@ WeatherProvider.register("weatherbit", {
this.fetchedLocationName = `${data.city_name}, ${data.state_code}`;
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.weatherbit] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -79,7 +79,7 @@ WeatherProvider.register("weatherbit", {
this.config.weatherEndpoint = "/current";
break;
default:
Log.error("weatherEndpoint not configured and could not resolve it based on type");
Log.error("[weatherprovider.weatherbit] weatherEndpoint not configured and could not resolve it based on type");
}
}
},

View File

@@ -41,7 +41,7 @@ WeatherProvider.register("weatherflow", {
this.fetchedLocationName = data.location_name;
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.weatherflow] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -81,7 +81,7 @@ WeatherProvider.register("weatherflow", {
this.fetchedLocationName = data.location_name;
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.weatherflow] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -112,7 +112,7 @@ WeatherProvider.register("weatherflow", {
this.fetchedLocationName = data.location_name;
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.weatherflow] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},

View File

@@ -41,11 +41,6 @@ WeatherProvider.register("weathergov", {
this.fetchWxGovURLs(this.config);
},
// Called when the weather provider is about to start.
start () {
Log.info(`Weather provider: ${this.providerName} started.`);
},
// This returns the name of the fetched location or an empty string.
fetchedLocation () {
return this.fetchedLocationName || "";
@@ -54,7 +49,7 @@ WeatherProvider.register("weathergov", {
// Overwrite the fetchCurrentWeather method.
fetchCurrentWeather () {
if (!this.configURLs) {
Log.info("fetchCurrentWeather: fetch wx waiting on config URLs");
Log.info("[weatherprovider.weathergov] fetchCurrentWeather: fetch wx waiting on config URLs");
return;
}
this.fetchData(this.stationObsURL)
@@ -67,7 +62,7 @@ WeatherProvider.register("weathergov", {
this.setCurrentWeather(currentWeather);
})
.catch(function (request) {
Log.error("Could not load station obs data ... ", request);
Log.error("[weatherprovider.weathergov] Could not load station obs data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -75,7 +70,7 @@ WeatherProvider.register("weathergov", {
// Overwrite the fetchWeatherForecast method.
fetchWeatherForecast () {
if (!this.configURLs) {
Log.info("fetchWeatherForecast: fetch wx waiting on config URLs");
Log.info("[weatherprovider.weathergov] fetchWeatherForecast: fetch wx waiting on config URLs");
return;
}
this.fetchData(this.forecastURL)
@@ -88,7 +83,7 @@ WeatherProvider.register("weathergov", {
this.setWeatherForecast(forecast);
})
.catch(function (request) {
Log.error("Could not load forecast hourly data ... ", request);
Log.error("[weatherprovider.weathergov] Could not load forecast hourly data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -96,7 +91,7 @@ WeatherProvider.register("weathergov", {
// Overwrite the fetchWeatherHourly method.
fetchWeatherHourly () {
if (!this.configURLs) {
Log.info("fetchWeatherHourly: fetch wx waiting on config URLs");
Log.info("[weatherprovider.weathergov] fetchWeatherHourly: fetch wx waiting on config URLs");
return;
}
this.fetchData(this.forecastHourlyURL)
@@ -113,7 +108,7 @@ WeatherProvider.register("weathergov", {
this.setWeatherHourly(hourly);
})
.catch(function (request) {
Log.error("Could not load data ... ", request);
Log.error("[weatherprovider.weathergov] Could not load data ... ", request);
})
.finally(() => this.updateAvailable());
},
@@ -131,7 +126,7 @@ WeatherProvider.register("weathergov", {
return;
}
this.fetchedLocationName = `${data.properties.relativeLocation.properties.city}, ${data.properties.relativeLocation.properties.state}`;
Log.log(`Forecast location is ${this.fetchedLocationName}`);
Log.log(`[weatherprovider.weathergov] Forecast location is ${this.fetchedLocationName}`);
this.forecastURL = `${data.properties.forecast}?units=si`;
this.forecastHourlyURL = `${data.properties.forecastHourly}?units=si`;
this.forecastGridDataURL = data.properties.forecastGridData;
@@ -147,7 +142,7 @@ WeatherProvider.register("weathergov", {
this.stationObsURL = `${obsData.features[0].id}/observations/latest`;
})
.catch((err) => {
Log.error(err);
Log.error("[weatherprovider.weathergov] fetchWxGovURLs error: ", err);
})
.finally(() => {
// excellent, let's fetch some actual wx data

View File

@@ -20,14 +20,14 @@ WeatherProvider.register("yr", {
start () {
if (typeof Storage === "undefined") {
//local storage unavailable
Log.error("The Yr weather provider requires local storage.");
Log.error("[weatherprovider.yr] The Yr weather provider requires local storage.");
throw new Error("Local storage not available");
}
if (this.config.updateInterval < 600000) {
Log.warn("The Yr weather provider requires a minimum update interval of 10 minutes (600 000 ms). The configuration has been adjusted to meet this requirement.");
Log.warn("[weatherprovider.yr] The Yr weather provider requires a minimum update interval of 10 minutes (600 000 ms). The configuration has been adjusted to meet this requirement.");
this.delegate.config.updateInterval = 600000;
}
Log.info(`Weather provider: ${this.providerName} started.`);
Log.info(`[weatherprovider.yr] ${this.providerName} started.`);
},
fetchCurrentWeather () {
@@ -37,7 +37,7 @@ WeatherProvider.register("yr", {
this.updateAvailable();
})
.catch((error) => {
Log.error(error);
Log.error("[weatherprovider.yr] fetchCurrentWeather error:", error);
this.updateAvailable();
});
},
@@ -45,10 +45,10 @@ WeatherProvider.register("yr", {
async getCurrentWeather () {
const [weatherData, stellarData] = await Promise.all([this.getWeatherData(), this.getStellarData()]);
if (!stellarData) {
Log.warn("No stellar data available.");
Log.warn("[weatherprovider.yr] No stellar data available.");
}
if (!weatherData.properties.timeseries || !weatherData.properties.timeseries[0]) {
Log.error("No weather data available.");
Log.error("[weatherprovider.yr] No weather data available.");
return;
}
const currentTime = moment();
@@ -105,12 +105,12 @@ WeatherProvider.register("yr", {
let weatherData = this.getWeatherDataFromCache();
if (this.weatherDataIsValid(weatherData)) {
localStorage.removeItem("yrIsFetchingWeatherData");
Log.debug("Weather data found in cache.");
Log.debug("[weatherprovider.yr] Weather data found in cache.");
resolve(weatherData);
} else {
this.getWeatherDataFromYr(weatherData?.downloadedAt)
.then((weatherData) => {
Log.debug("Got weather data from yr.");
Log.debug("[weatherprovider.yr] Got weather data from yr.");
let data;
if (weatherData) {
this.cacheWeatherData(weatherData);
@@ -122,9 +122,9 @@ WeatherProvider.register("yr", {
resolve(data);
})
.catch((err) => {
Log.error(err);
Log.error("[weatherprovider.yr] getWeatherDataFromYr error: ", err);
if (weatherData) {
Log.warn("Using outdated cached weather data.");
Log.warn("[weatherprovider.yr] Using outdated cached weather data.");
resolve(weatherData);
} else {
reject("Unable to get weather data from Yr.");
@@ -171,18 +171,18 @@ WeatherProvider.register("yr", {
return data;
})
.catch((err) => {
Log.error("Could not load weather data.", err);
Log.error("[weatherprovider.yr] Could not load weather data.", err);
throw new Error(err);
});
},
getConfigOptions () {
if (!this.config.lat) {
Log.error("Latitude not provided.");
Log.error("[weatherprovider.yr] Latitude not provided.");
throw new Error("Latitude not provided.");
}
if (!this.config.lon) {
Log.error("Longitude not provided.");
Log.error("[weatherprovider.yr] Longitude not provided.");
throw new Error("Longitude not provided.");
}
@@ -196,12 +196,12 @@ WeatherProvider.register("yr", {
let { lat, lon, altitude } = this.getConfigOptions();
if (lat.includes(".") && lat.split(".")[1].length > 4) {
Log.warn("Latitude is too specific for weather data. Do not use more than four decimals. Trimming to maximum length.");
Log.warn("[weatherprovider.yr] Latitude is too specific for weather data. Do not use more than four decimals. Trimming to maximum length.");
const latParts = lat.split(".");
lat = `${latParts[0]}.${latParts[1].substring(0, 4)}`;
}
if (lon.includes(".") && lon.split(".")[1].length > 4) {
Log.warn("Longitude is too specific for weather data. Do not use more than four decimals. Trimming to maximum length.");
Log.warn("[weatherprovider.yr] Longitude is too specific for weather data. Do not use more than four decimals. Trimming to maximum length.");
const lonParts = lon.split(".");
lon = `${lonParts[0]}.${lonParts[1].substring(0, 4)}`;
}
@@ -249,11 +249,11 @@ WeatherProvider.register("yr", {
const today = moment().format("YYYY-MM-DD");
const tomorrow = moment().add(1, "days").format("YYYY-MM-DD");
if (stellarData && stellarData.today && stellarData.today.date === today && stellarData.tomorrow && stellarData.tomorrow.date === tomorrow) {
Log.debug("Stellar data found in cache.");
Log.debug("[weatherprovider.yr] Stellar data found in cache.");
localStorage.removeItem("yrIsFetchingStellarData");
resolve(stellarData);
} else if (stellarData && stellarData.tomorrow && stellarData.tomorrow.date === today) {
Log.debug("stellar data for today found in cache, but not for tomorrow.");
Log.debug("[weatherprovider.yr] Stellar data for today found in cache, but not for tomorrow.");
stellarData.today = stellarData.tomorrow;
this.getStellarDataFromYr(tomorrow)
.then((data) => {
@@ -267,7 +267,7 @@ WeatherProvider.register("yr", {
}
})
.catch((err) => {
Log.error(err);
Log.error("[weatherprovider.yr] getStellarDataFromYr error: ", err);
reject(`Unable to get stellar data from Yr for ${tomorrow}`);
})
.finally(() => {
@@ -286,12 +286,12 @@ WeatherProvider.register("yr", {
this.cacheStellarData(data);
resolve(data);
} else {
Log.error(`Something went wrong when fetching stellar data. Responses: ${stellarData}`);
Log.error(`[weatherprovider.yr] Something went wrong when fetching stellar data. Responses: ${stellarData}`);
reject(stellarData);
}
})
.catch((err) => {
Log.error(err);
Log.error("[weatherprovider.yr] getStellarDataFromYr error: ", err);
reject("Unable to get stellar data from Yr.");
})
.finally(() => {
@@ -313,11 +313,11 @@ WeatherProvider.register("yr", {
const requestHeaders = [{ name: "Accept", value: "application/json" }];
return this.fetchData(this.getStellarDataUrl(date, days), "json", requestHeaders)
.then((data) => {
Log.debug("Got stellar data from yr.");
Log.debug("[weatherprovider.yr] Got stellar data from yr.");
return data;
})
.catch((err) => {
Log.error("Could not load weather data.", err);
Log.error("[weatherprovider.yr] Could not load weather data.", err);
throw new Error(err);
});
},
@@ -326,12 +326,12 @@ WeatherProvider.register("yr", {
let { lat, lon, altitude } = this.getConfigOptions();
if (lat.includes(".") && lat.split(".")[1].length > 4) {
Log.warn("Latitude is too specific for stellar data. Do not use more than four decimals. Trimming to maximum length.");
Log.warn("[weatherprovider.yr] Latitude is too specific for stellar data. Do not use more than four decimals. Trimming to maximum length.");
const latParts = lat.split(".");
lat = `${latParts[0]}.${latParts[1].substring(0, 4)}`;
}
if (lon.includes(".") && lon.split(".")[1].length > 4) {
Log.warn("Longitude is too specific for stellar data. Do not use more than four decimals. Trimming to maximum length.");
Log.warn("[weatherprovider.yr] Longitude is too specific for stellar data. Do not use more than four decimals. Trimming to maximum length.");
const lonParts = lon.split(".");
lon = `${lonParts[0]}.${lonParts[1].substring(0, 4)}`;
}
@@ -505,7 +505,7 @@ WeatherProvider.register("yr", {
this.updateAvailable();
})
.catch((error) => {
Log.error(error);
Log.error("[weatherprovider.yr] fetchWeatherHourly error: ", error);
this.updateAvailable();
});
},
@@ -513,11 +513,11 @@ WeatherProvider.register("yr", {
async getWeatherForecast (type) {
const [weatherData, stellarData] = await Promise.all([this.getWeatherData(), this.getStellarData()]);
if (!weatherData.properties.timeseries || !weatherData.properties.timeseries[0]) {
Log.error("No weather data available.");
Log.error("[weatherprovider.yr] No weather data available.");
return;
}
if (!stellarData) {
Log.warn("No stellar data available.");
Log.warn("[weatherprovider.yr] No stellar data available.");
}
let forecasts;
switch (type) {
@@ -616,7 +616,7 @@ WeatherProvider.register("yr", {
this.updateAvailable();
})
.catch((error) => {
Log.error(error);
Log.error("[weatherprovider.yr] fetchWeatherForecast error: ", error);
this.updateAvailable();
});
}

View File

@@ -76,10 +76,10 @@ Module.register("weather", {
moment.locale(this.config.lang);
if (this.config.useKmh) {
Log.warn("Your are using the deprecated config values 'useKmh'. Please switch to windUnits!");
Log.warn("[weather] Deprecation warning: Your are using the deprecated config values 'useKmh'. Please switch to windUnits!");
this.windUnits = "kmh";
} else if (this.config.useBeaufort) {
Log.warn("Your are using the deprecated config values 'useBeaufort'. Please switch to windUnits!");
Log.warn("[weather] Deprecation warning: Your are using the deprecated config values 'useBeaufort'. Please switch to windUnits!");
this.windUnits = "beaufort";
}
if (typeof this.config.showHumidity === "boolean") {
@@ -109,7 +109,7 @@ Module.register("weather", {
for (let event of payload) {
if (event.location || event.geo) {
this.firstEvent = event;
Log.debug("First upcoming event with location: ", event);
Log.debug("[weather] First upcoming event with location: ", event);
break;
}
}
@@ -163,7 +163,7 @@ Module.register("weather", {
// What to do when the weather provider has new information available?
updateAvailable () {
Log.log("New weather information available.");
Log.log("[weather] New weather information available.");
// this value was changed from 0 to 300 to stabilize weather tests:
this.updateDom(300);
this.scheduleUpdate();
@@ -208,7 +208,7 @@ Module.register("weather", {
this.weatherProvider.fetchWeatherForecast();
break;
default:
Log.error(`Invalid type ${this.config.type} configured (must be one of 'current', 'hourly', 'daily' or 'forecast')`);
Log.error(`[weather] Invalid type ${this.config.type} configured (must be one of 'current', 'hourly', 'daily' or 'forecast')`);
}
}, nextLoad);
},

View File

@@ -25,36 +25,36 @@ const WeatherProvider = Class.extend({
// Called when a weather provider is initialized.
init (config) {
this.config = config;
Log.info(`Weather provider: ${this.providerName} initialized.`);
Log.info(`[weatherprovider] ${this.providerName} initialized.`);
},
// Called to set the config, this config is the same as the weather module's config.
setConfig (config) {
this.config = config;
Log.info(`Weather provider: ${this.providerName} config set.`, this.config);
Log.info(`[weatherprovider] ${this.providerName} config set.`, this.config);
},
// Called when the weather provider is about to start.
start () {
Log.info(`Weather provider: ${this.providerName} started.`);
Log.info(`[weatherprovider] ${this.providerName} started.`);
},
// This method should start the API request to fetch the current weather.
// This method should definitely be overwritten in the provider.
fetchCurrentWeather () {
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchCurrentWeather method.`);
Log.warn(`[weatherprovider] ${this.providerName} does not subclass the fetchCurrentWeather method.`);
},
// This method should start the API request to fetch the weather forecast.
// This method should definitely be overwritten in the provider.
fetchWeatherForecast () {
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherForecast method.`);
Log.warn(`[weatherprovider] ${this.providerName} does not subclass the fetchWeatherForecast method.`);
},
// This method should start the API request to fetch the weather hourly.
// This method should definitely be overwritten in the provider.
fetchWeatherHourly () {
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherHourly method.`);
Log.warn(`[weatherprovider] ${this.providerName} does not subclass the fetchWeatherHourly method.`);
},
// This returns a WeatherDay object for the current weather.
@@ -109,7 +109,7 @@ const WeatherProvider = Class.extend({
* @param {string} url the url to fetch from
* @param {string} type what contenttype to expect in the response, can be "json" or "xml"
* @param {Array.<{name: string, value:string}>} requestHeaders the HTTP headers to send
* @param {Array.<string>} expectedResponseHeaders the expected HTTP headers to recieve
* @param {Array.<string>} expectedResponseHeaders the expected HTTP headers to receive
* @returns {Promise} resolved when the fetch is done
*/
async fetchData (url, type = "json", requestHeaders = undefined, expectedResponseHeaders = undefined) {