Use correct log level in development mode and use log.debug() for some of the reoccurring logs

pull/49/head
sachaaaaa 7 years ago
parent ef44a123ed
commit ccb5ff79d4

@ -53,6 +53,12 @@ function log(...args) {
if (window.console) { if (window.console) {
console._log = console.log; console._log = console.log;
console.log = log; console.log = log;
console._trace = console.trace;
console._debug = console.debug
console._info = console.info;
console._warn = console.warn;
console._error = console.error;
console._fatal = console.error;
} }
// The mechanics of preparing a log for publish // The mechanics of preparing a log for publish
@ -95,12 +101,18 @@ function fetch() {
} }
const publish = debuglogs.upload; const publish = debuglogs.upload;
const development = (window.getEnvironment() !== 'production');
// A modern logging interface for the browser // A modern logging interface for the browser
// The Bunyan API: https://github.com/trentm/node-bunyan#log-method-api // The Bunyan API: https://github.com/trentm/node-bunyan#log-method-api
function logAtLevel(level, prefix, ...args) { function logAtLevel(level, prefix, ...args) {
console._log(prefix, now(), ...args); if (development) {
const fn = `_${level}`;
console[fn](prefix, now(), ...args);
} else {
console._log(prefix, now(), ...args);
}
const str = cleanArgsForIPC(args); const str = cleanArgsForIPC(args);
const logText = Privacy.redactAll(str); const logText = Privacy.redactAll(str);

@ -73,7 +73,7 @@ class LokiServer {
timeout: undefined, timeout: undefined,
}; };
log.info(options.type, options.url); log.debug(options.type, options.url);
const fetchOptions = { const fetchOptions = {
method: options.type, method: options.type,
@ -108,7 +108,7 @@ class LokiServer {
} }
if (response.status >= 0 && response.status < 400) { if (response.status >= 0 && response.status < 400) {
log.info(options.type, options.url, response.status, 'Success'); log.debug(options.type, options.url, response.status, 'Success');
return result; return result;
} }
log.error(options.type, options.url, response.status, 'Error'); log.error(options.type, options.url, response.status, 'Error');
@ -126,7 +126,7 @@ class LokiServer {
timeout: undefined, timeout: undefined,
}; };
log.info(options.type, options.url); log.debug(options.type, options.url);
const headers = { const headers = {
'X-Loki-recipient': pubKey, 'X-Loki-recipient': pubKey,
@ -163,7 +163,7 @@ class LokiServer {
} }
if (response.status >= 0 && response.status < 400) { if (response.status >= 0 && response.status < 400) {
log.info(options.type, options.url, response.status, 'Success'); log.debug(options.type, options.url, response.status, 'Success');
if (result.lastHash) { if (result.lastHash) {
currentNode.lastHash = result.lastHash; currentNode.lastHash = result.lastHash;
} }

@ -365,7 +365,7 @@ MessageReceiver.prototype.extend({
this.incoming = []; this.incoming = [];
const dispatchEmpty = () => { const dispatchEmpty = () => {
window.log.info("MessageReceiver: emitting 'empty' event"); window.log.debug("MessageReceiver: emitting 'empty' event");
const ev = new Event('empty'); const ev = new Event('empty');
return this.dispatchAndWait(ev); return this.dispatchAndWait(ev);
}; };

Loading…
Cancel
Save