Skip to content

Commit

Permalink
Fix: Log error stack style
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jan 15, 2017
1 parent ae3504e commit f7fc6d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Console/Log.es6
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class Log
break;
}

msg = recognizeUrl(msg);
if (type !== 'error') msg = recognizeUrl(msg);
this.value = msg;
msg = render({msg, type, icon, id, displayHeader, time, from});

Expand Down Expand Up @@ -224,19 +224,19 @@ function formatTable(args)
return ret;
}

var regErudaJs = /eruda(\.min)?\.js/;
var regJsUrl = /https?:\/\/([0-9.\-A-Za-z]+)(?::(\d+))?\/[A-Z.a-z0-9/]*\.js/g,
regErudaJs = /eruda(\.min)?\.js/;

function formatErr(err)
{
var lines = err.stack.split('\n'),
msg = `${err.message || lines[0]}<br/>`;

lines = lines.filter(val => !regErudaJs.test(val));
lines = lines.map(val => util.trim(val));

var stack = `<div class="eruda-stack eruda-hidden">${lines.slice(1).join('<br/>')}</div>`;

return msg + stack;
return msg + stack.replace(regJsUrl, match => `<a href="${match}" target="_blank">${match}</a>`);
}

function formatJs(code)
Expand Down Expand Up @@ -364,7 +364,7 @@ function formatEl(val)

var regUrl = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g;

var recognizeUrl = (str) => str.replace(regUrl, match => `<a href="${match}" target="_blank">${match}</a>`);
var recognizeUrl = str => str.replace(regUrl, match => `<a href="${match}" target="_blank">${match}</a>`);

function getFrom()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Logger.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
.stack {
color: $gray-dark;
padding-left: 1.2em;
white-space: normal;
}
.count {
background: $red;
Expand All @@ -112,4 +113,4 @@
}
}
}
} } }
} } }

0 comments on commit f7fc6d7

Please sign in to comment.