node: Improved message logging
This commit is contained in:
parent
d77b5d5abe
commit
cdebbe5bb7
|
|
@ -461,17 +461,17 @@ impl Message {
|
|||
};
|
||||
let msg = match self {
|
||||
Self::Announcement(Announcement { node, message, .. }) => match message {
|
||||
AnnouncementMessage::Node(NodeAnnouncement { addresses, .. }) => format!(
|
||||
"{verb} node announcement of {node} with {} address(es) {prep} {remote}",
|
||||
AnnouncementMessage::Node(NodeAnnouncement { addresses, timestamp, .. }) => format!(
|
||||
"{verb} node announcement of {node} with {} address(es) {prep} {remote} (t={timestamp})",
|
||||
addresses.len()
|
||||
),
|
||||
AnnouncementMessage::Refs(RefsAnnouncement { rid, refs, .. }) => format!(
|
||||
"{verb} refs announcement of {node} for {rid} with {} remote(s) {prep} {remote}",
|
||||
AnnouncementMessage::Refs(RefsAnnouncement { rid, refs, timestamp }) => format!(
|
||||
"{verb} refs announcement of {node} for {rid} with {} remote(s) {prep} {remote} (t={timestamp})",
|
||||
refs.len()
|
||||
),
|
||||
AnnouncementMessage::Inventory(InventoryAnnouncement { inventory, .. }) => {
|
||||
AnnouncementMessage::Inventory(InventoryAnnouncement { inventory, timestamp }) => {
|
||||
format!(
|
||||
"{verb} inventory announcement of {node} with {} item(s) {prep} {remote}",
|
||||
"{verb} inventory announcement of {node} with {} item(s) {prep} {remote} (t={timestamp})",
|
||||
inventory.len()
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,22 @@ impl Log for Logger {
|
|||
|
||||
fn log(&self, record: &Record) {
|
||||
use colored::Colorize;
|
||||
let time = LocalTime::now().as_secs();
|
||||
|
||||
match record.target() {
|
||||
"test" => {
|
||||
println!("{} {}", "test:".cyan(), record.args().to_string().cyan())
|
||||
println!(
|
||||
"{time} {} {}",
|
||||
"test:".cyan(),
|
||||
record.args().to_string().cyan()
|
||||
)
|
||||
}
|
||||
"sim" => {
|
||||
println!("{} {}", "sim:".bold(), record.args().to_string().bold())
|
||||
println!(
|
||||
"{time} {} {}",
|
||||
"sim:".bold(),
|
||||
record.args().to_string().bold()
|
||||
)
|
||||
}
|
||||
target => {
|
||||
if self.enabled(record.metadata()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue