Merge pull request #1331 from flyingchipmunk/dev_newsfeed_logging

Add option to newsfeed for logging errors
This commit is contained in:
Michael Teeuw 2018-06-27 02:39:14 +02:00 committed by GitHub
commit d534dbb006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 4 deletions

View File

@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Ability to fetch compliments from a remote server - Ability to fetch compliments from a remote server
- Add regex filtering to calendar module - Add regex filtering to calendar module
- Customize classes for table - Customize classes for table
- Added option to newsfeed module to only log error parsing a news article if enabled
### Changed ### Changed
- Upgrade to Electron 2.0.0. - Upgrade to Electron 2.0.0.

View File

@ -80,6 +80,7 @@ The following properties can be configured:
| `endTags` | List the tags you would like to have removed at the end of the feed item <br><br> **Possible values:** `['TAG']` or `['TAG1','TAG2',...]` | `endTags` | List the tags you would like to have removed at the end of the feed item <br><br> **Possible values:** `['TAG']` or `['TAG1','TAG2',...]`
| `prohibitedWords` | Remove news feed item if one of these words is found anywhere in the title (case insensitive and greedy matching) <br><br> **Possible values:** `['word']` or `['word1','word2',...]` | `prohibitedWords` | Remove news feed item if one of these words is found anywhere in the title (case insensitive and greedy matching) <br><br> **Possible values:** `['word']` or `['word1','word2',...]`
| `scrollLength` | Scrolls the full news article page by a given number of pixels when a `ARTICLE_MORE_DETAILS` notification is received and the full news article is already displayed.<br><br> **Possible values:** `1` or `10000` <br> **Default value:** `500` | `scrollLength` | Scrolls the full news article page by a given number of pixels when a `ARTICLE_MORE_DETAILS` notification is received and the full news article is already displayed.<br><br> **Possible values:** `1` or `10000` <br> **Default value:** `500`
| `logFeedWarnings` | Log warnings when there is an error parsing a news article. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
The `feeds` property contains an array with multiple objects. These objects have the following properties: The `feeds` property contains an array with multiple objects. These objects have the following properties:

View File

@ -14,9 +14,10 @@ var iconv = require("iconv-lite");
* *
* attribute url string - URL of the news feed. * attribute url string - URL of the news feed.
* attribute reloadInterval number - Reload interval in milliseconds. * attribute reloadInterval number - Reload interval in milliseconds.
* attribute logFeedWarnings boolean - Log warnings when there is an error parsing a news article.
*/ */
var Fetcher = function(url, reloadInterval, encoding) { var Fetcher = function(url, reloadInterval, encoding, logFeedWarnings) {
var self = this; var self = this;
if (reloadInterval < 1000) { if (reloadInterval < 1000) {
reloadInterval = 1000; reloadInterval = 1000;
@ -60,7 +61,7 @@ var Fetcher = function(url, reloadInterval, encoding) {
url: url, url: url,
}); });
} else { } else if (logFeedWarnings) {
console.log("Can't parse feed item:"); console.log("Can't parse feed item:");
console.log(item); console.log(item);
console.log("Title: " + title); console.log("Title: " + title);

View File

@ -37,7 +37,8 @@ Module.register("newsfeed",{
startTags: [], startTags: [],
endTags: [], endTags: [],
prohibitedWords: [], prohibitedWords: [],
scrollLength: 500 scrollLength: 500,
logFeedWarnings: false
}, },
// Define required scripts. // Define required scripts.

View File

@ -46,7 +46,7 @@ module.exports = NodeHelper.create({
var fetcher; var fetcher;
if (typeof self.fetchers[url] === "undefined") { if (typeof self.fetchers[url] === "undefined") {
console.log("Create new news fetcher for url: " + url + " - Interval: " + reloadInterval); console.log("Create new news fetcher for url: " + url + " - Interval: " + reloadInterval);
fetcher = new Fetcher(url, reloadInterval, encoding); fetcher = new Fetcher(url, reloadInterval, encoding, config.logFeedWarnings);
fetcher.onReceive(function(fetcher) { fetcher.onReceive(function(fetcher) {
self.broadcastFeeds(); self.broadcastFeeds();