electron-log
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -5,8 +5,9 @@ # Changelog | ||
- Helper for custom log levels: log.levels.add | ||
- Feature: Helper for custom log levels: log.levels.add | ||
- Stringify Errors instead of converting to object | ||
- Feature: Submit error report to github or other source | ||
## 4.1.0 | ||
- New feature: scopes | ||
- Feature: Scopes | ||
@@ -13,0 +14,0 @@ ## 4.0.0 |
{ | ||
"name": "electron-log", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "Just a very simple logging module for your Electron application", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -157,3 +157,3 @@ # electron-log | ||
### Catch errors | ||
### [Catch errors](docs/catch.md) | ||
@@ -164,9 +164,4 @@ electron-log can catch and log unhandled errors/rejected promises: | ||
##### Options | ||
[More info](docs/catch.md). | ||
- **showDialog**, default true for the main process. false prevents | ||
showing a default electron error dialog | ||
- **onError**, `(error) => void | false`, default null - attach a custom | ||
error handler. If the handler returns false, this error will not be processed. | ||
### [Hooks](docs/extend.md#hooks) | ||
@@ -173,0 +168,0 @@ |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var electronApi = require('./electronApi'); | ||
var queryString = require('querystring'); | ||
@@ -29,3 +30,4 @@ var isAttached = false; | ||
if (typeof options.onError === 'function') { | ||
if (options.onError(e) === false) { | ||
var versions = electronApi.getVersions(); | ||
if (options.onError(e, versions, createIssue) === false) { | ||
return; | ||
@@ -91,2 +93,7 @@ } | ||
} | ||
function createIssue(pageUrl, queryParams) { | ||
var issueUrl = pageUrl + '?' + queryString.stringify(queryParams); | ||
electronApi.openUrl(issueUrl, options.log); | ||
} | ||
}; |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var os = require('os'); | ||
module.exports = { | ||
@@ -20,2 +22,3 @@ getName: getName, | ||
getVersion: getVersion, | ||
getVersions: getVersions, | ||
isDev: isDev, | ||
@@ -26,2 +29,3 @@ isElectron: isElectron, | ||
onIpc: onIpc, | ||
openUrl: openUrl, | ||
sendIpc: sendIpc, | ||
@@ -97,2 +101,27 @@ showErrorBox: showErrorBox, | ||
function getVersions() { | ||
return { | ||
app: getName() + ' ' + getVersion(), | ||
electron: 'Electron ' + process.versions.electron, | ||
os: getOsVersion(), | ||
}; | ||
} | ||
function getOsVersion() { | ||
var osName = os.type().replace('_', ' '); | ||
var osVersion = os.release(); | ||
if (osName === 'Darwin') { | ||
osName = 'macOS'; | ||
osVersion = getMacOsVersion(); | ||
} | ||
return osName + ' ' + osVersion; | ||
} | ||
function getMacOsVersion() { | ||
var release = Number(os.release().split('.')[0]); | ||
return '10.' + (release - 4); | ||
} | ||
function isDev() { | ||
@@ -192,1 +221,15 @@ // based on sindresorhus/electron-is-dev | ||
} | ||
/** | ||
* @param {string} url | ||
* @param {Function} [logFunction] | ||
*/ | ||
function openUrl(url, logFunction) { | ||
// eslint-disable-next-line no-console | ||
logFunction = logFunction || console.error; | ||
var shell = getElectronModule('shell'); | ||
if (!shell) return; | ||
shell.openExternal(url).catch(logFunction); | ||
} |
@@ -338,2 +338,13 @@ import { RequestOptions } from "http"; | ||
interface ReportData { | ||
body: string; | ||
title: string; | ||
assignee: string; | ||
labels: string; | ||
milestone: string; | ||
projects: string; | ||
template: string; | ||
} | ||
interface CatchErrorsOptions { | ||
@@ -350,3 +361,7 @@ /** | ||
*/ | ||
onError? (error: Error): void; | ||
onError?( | ||
error: Error, | ||
versions?: { app: string; electron: string; os: string }, | ||
submitIssue?: (url: string, data: ReportData | any) => void, | ||
): void; | ||
} | ||
@@ -353,0 +368,0 @@ |
@@ -19,5 +19,7 @@ 'use strict'; | ||
var registry = customRegistry || globalRegistry; | ||
registry.on('error', function (e, file) { | ||
logConsole('Can\'t write to ' + file, e); | ||
}); | ||
if (registry.listenerCount('error') < 1) { | ||
registry.on('error', function (e, file) { | ||
logConsole('Can\'t write to ' + file, e); | ||
}); | ||
} | ||
@@ -24,0 +26,0 @@ /* eslint-disable no-multi-spaces */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63112
1918
203