Skip to content

Commit

Permalink
Merge branch 'leo-ckbtc-remove-logs-from-dashboard' into 'master'
Browse files Browse the repository at this point in the history
feat(ckbtc): Remove logs from dashboard

The dashboard page will become a problem when the page becomes bigger than 2MB, as of 25/01/2024 the minter dashboard is 1.93MB.

A quick fix is to remove the logs from the dashboard as they have their dedicated endpoint `/logs`.

Long-term https://dfinity.atlassian.net/browse/XC-39 should be implemented. 

See merge request dfinity-lab/public/ic!17330
  • Loading branch information
leokazz committed Jan 25, 2024
2 parents fa7e0e8 + 08d14d2 commit 5b6101f
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions rs/bitcoin/ckbtc/minter/src/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ pub fn build_dashboard() -> Vec<u8> {
<ul>{}</ul>
<h3>Retrieve BTC principals pending</h3>
<ul>{}</ul>
<h3>Logs</h3>
<table>
<thead><tr><th>Priority</th><th>Timestamp</th><th>Location</th><th>Message</th></tr></thead>
<tbody>{}</tbody>
</table>
</div></div>
</body>
</html>",
Expand All @@ -203,7 +198,6 @@ pub fn build_dashboard() -> Vec<u8> {
build_account_to_utxos_table(),
build_update_balance_principals(),
build_retrieve_btc_principals(),
display_logs(),
);
html.into_bytes()
}
Expand Down Expand Up @@ -566,46 +560,6 @@ pub fn build_retrieve_btc_principals() -> String {
})
}

fn display_logs() -> String {
use crate::logs::{P0, P1};
use ic_canister_log::{export, LogEntry};

fn display_entry(buf: &mut Vec<u8>, tag: &str, e: &LogEntry) {
write!(
buf,
"<tr><td>{}</td><td class=\"ts-class\">{}</td><td><code>{}:{}</code></td><td>{}</td></tr>",
tag, e.timestamp, e.file, e.line, e.message
)
.unwrap()
}

let p0 = export(&P0);
let p1 = export(&P1);

let mut i0 = 0;
let mut i1 = 0;

with_utf8_buffer(|buf| {
// Merge sorted log entries with different priorities.
while i0 < p0.len() && i1 < p1.len() {
if p0[i0].timestamp <= p1[i1].timestamp {
display_entry(buf, "P0", &p0[i0]);
i0 += 1;
} else {
display_entry(buf, "P1", &p1[i1]);
i1 += 1;
}
}

for e in p0[i0..].iter() {
display_entry(buf, "P0", e);
}
for e in p1[i1..].iter() {
display_entry(buf, "P1", e);
}
})
}

fn txid_link(txid: &Txid) -> String {
txid_link_on(txid, state::read_state(|s| s.btc_network))
}
Expand Down

0 comments on commit 5b6101f

Please sign in to comment.