Skip to content

Commit

Permalink
Add recommendation to enable 'preserve log' (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmondChuiHW authored Oct 15, 2024
1 parent 78fc3dc commit 6f29504
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions front_end/panels/console/ConsoleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,14 @@ export class ConsoleView extends UI.Widget.VBox implements
if (!Common.Settings.Settings.instance().moduleSetting('preserve-console-log').get() &&
model.target().outermostTarget() === model.target()) {
this.consoleCleared();
this.addConsoleMessage(new SDK.ConsoleModel.ConsoleMessage(
model.target().model(SDK.RuntimeModel.RuntimeModel), Protocol.Log.LogEntrySource.Recommendation,
Protocol.Log.LogEntryLevel.Info,
'[React Native] Console messages are currently cleared upon DevTools disconnection. You can preserve logs in settings: ',
{
type: SDK.ConsoleModel.FrontendMessageType.System,
context: 'fusebox_preserve_log_rec',
}));
}
}

Expand Down
11 changes: 11 additions & 0 deletions front_end/panels/console/ConsoleViewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,17 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
formattedMessage.appendChild(this.anchorElement);
}
formattedMessage.appendChild(messageElement);

if (this.message.context === 'fusebox_preserve_log_rec') {
const link = document.createElement('button');
link.classList.add('devtools-link', 'text-button', 'link-style');
link.appendChild(link.ownerDocument.createTextNode('show settings'));
link.addEventListener('click', async () => {
await Common.Revealer.reveal(Common.Settings.Settings.instance().moduleSetting('preserve-console-log'));
});
formattedMessage.appendChild(link);
}

return formattedMessage;
}

Expand Down
1 change: 1 addition & 0 deletions front_end/ui/components/settings/settingCheckbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

:host {
display: block;
padding: 0;
margin: 0;
}
Expand Down

0 comments on commit 6f29504

Please sign in to comment.