mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
Auto-Redact personal information from logs (#421)
This commit is contained in:
parent
4c8bd7a70c
commit
6eb769e6d5
2 changed files with 27 additions and 0 deletions
|
@ -76,6 +76,17 @@ i.very-large {
|
|||
.log-underline { text-decoration: underline; }
|
||||
.log-strikethrough { text-decoration: line-through; }
|
||||
.log-underline.log-strikethrough { text-decoration: underline line-through; }
|
||||
.log-secret {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.log-secret-redacted {
|
||||
opacity: 0;
|
||||
width: 1px;
|
||||
font-size: 1px;
|
||||
}
|
||||
.log-fg-black { color: rgb(128,128,128); }
|
||||
.log-fg-red { color: rgb(255,0,0); }
|
||||
.log-fg-green { color: rgb(0,255,0); }
|
||||
|
|
|
@ -11,6 +11,7 @@ const initializeColorState = () => {
|
|||
foregroundColor: false,
|
||||
backgroundColor: false,
|
||||
carriageReturn: false,
|
||||
secret: false,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -43,10 +44,18 @@ const colorReplace = (pre, state, text) => {
|
|||
if (state.italic) span.classList.add("log-italic");
|
||||
if (state.underline) span.classList.add("log-underline");
|
||||
if (state.strikethrough) span.classList.add("log-strikethrough");
|
||||
if (state.secret) span.classList.add("log-secret");
|
||||
if (state.foregroundColor !== null) span.classList.add(`log-fg-${state.foregroundColor}`);
|
||||
if (state.backgroundColor !== null) span.classList.add(`log-bg-${state.backgroundColor}`);
|
||||
span.appendChild(document.createTextNode(content));
|
||||
lineSpan.appendChild(span);
|
||||
|
||||
if (state.secret) {
|
||||
const redacted = document.createElement("span");
|
||||
redacted.classList.add("log-secret-redacted");
|
||||
redacted.appendChild(document.createTextNode("[redacted]"));
|
||||
lineSpan.appendChild(redacted);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,6 +80,7 @@ const colorReplace = (pre, state, text) => {
|
|||
state.strikethrough = false;
|
||||
state.foregroundColor = null;
|
||||
state.backgroundColor = null;
|
||||
state.secret = false;
|
||||
break;
|
||||
case 1:
|
||||
state.bold = true;
|
||||
|
@ -81,6 +91,12 @@ const colorReplace = (pre, state, text) => {
|
|||
case 4:
|
||||
state.underline = true;
|
||||
break;
|
||||
case 5:
|
||||
state.secret = true;
|
||||
break;
|
||||
case 6:
|
||||
state.secret = false;
|
||||
break;
|
||||
case 9:
|
||||
state.strikethrough = true;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue