Skip to content

Commit

Permalink
use explicit imports for macros
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Apr 16, 2021
1 parent 7be2122 commit 9cd01d3
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 140 deletions.
2 changes: 1 addition & 1 deletion gtk/src/events/background/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn run(
) {
let send: &dyn Fn(UiEvent) = &send;
if let Ok(ref mut client) = Client::new() {
info!("Checking for updates to daemon");
log::info!("Checking for updates to daemon");
if client.update_and_restart().unwrap_or(false) {
send(UiEvent::Updating);
let file = std::path::Path::new(pop_upgrade::RESTART_SCHEDULED);
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/events/background/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use pop_upgrade::{
};

pub fn download(client: &Client, send: &dyn Fn(UiEvent), info: ReleaseInfo) {
info!("downloading updates for {}", info.next);
log::info!("downloading updates for {}", info.next);
if !update(client, send) {
return;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ pub fn download(client: &Client, send: &dyn Fn(UiEvent), info: ReleaseInfo) {
}

pub fn update(client: &Client, send: &dyn Fn(UiEvent)) -> bool {
info!("checking if updates are required");
log::info!("checking if updates are required");
let updates = match client.fetch_updates(Vec::new(), false) {
Ok(updates) => updates,
Err(why) => {
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/events/background/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn scan(client: &Client, send: &dyn Fn(UiEvent)) {
Ok(info) => {
is_lts = info.is_lts;
if devel || info.build >= 0 {
info!("upgrade from {} to {} is available", info.current, info.next);
log::info!("upgrade from {} to {} is available", info.current, info.next);

let upgrade_text = Cow::Owned(if reboot_ready {
format!("Pop!_OS is ready to upgrade to {}", info.next)
Expand All @@ -54,7 +54,7 @@ pub fn scan(client: &Client, send: &dyn Fn(UiEvent)) {
}
Err(why) => {
status_failed = true;
error!("failed to check for updates: {}", why);
log::error!("failed to check for updates: {}", why);
Cow::Borrowed("Failed to check for updates")
}
}
Expand Down
10 changes: 5 additions & 5 deletions gtk/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub fn attach(gui_receiver: glib::Receiver<UiEvent>, widgets: EventWidgets, mut
}

UiEvent::Completed(CompletedEvent::Recovery) => {
info!("successfully upgraded recovery partition");
log::info!("successfully upgraded recovery partition");
}

UiEvent::Completed(CompletedEvent::Refresh) => reboot(),
Expand Down Expand Up @@ -201,14 +201,14 @@ pub fn attach(gui_receiver: glib::Receiver<UiEvent>, widgets: EventWidgets, mut
UiEvent::ReleaseUpgradeDialog => release_upgrade_dialog(&mut state, &widgets),

UiEvent::Dismissed(dismissed) => {
info!("{} release", if dismissed { "dismissed" } else { "un-dismissed" });
log::info!("{} release", if dismissed { "dismissed" } else { "un-dismissed" });
if let Some(dismisser) = state.dismisser.as_mut() {
dismisser.set_dismissed(dismissed);
}
}

UiEvent::StatusChanged(from, to, why) => {
warn!("status changed from {} to {}: {}", from, to, why);
log::warn!("status changed from {} to {}: {}", from, to, why);
let _ = state.sender.send(BackgroundEvent::GetStatus(from));
}

Expand Down Expand Up @@ -267,7 +267,7 @@ fn connect_upgrade(state: &mut State, widgets: &EventWidgets, is_lts: bool, rebo
}
}
Err(why) => {
error!("failed to fetch EOL date: {}", why);
log::error!("failed to fetch EOL date: {}", why);
None
}
};
Expand Down Expand Up @@ -375,7 +375,7 @@ fn error(state: &mut State, widgets: &EventWidgets, why: UiError) {
.as_str(),
);

error!("{}", error_message);
log::error!("{}", error_message);

if let UiError::Dismiss(dismissed, _) = why {
if let Some(dismisser) = state.dismisser.as_mut() {
Expand Down
2 changes: 1 addition & 1 deletion src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum ValidateError {
}

pub async fn validate_checksum(file: &mut File, checksum: &str) -> Result<(), ValidateError> {
info!("validating checksum of downloaded ISO");
log::info!("validating checksum of downloaded ISO");
let expected = <[u8; 32]>::from_hex(checksum)
.map(GenericArray::from)
.map_err(|_| ValidateError::InvalidInput)?;
Expand Down
25 changes: 14 additions & 11 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ mod colors;

use self::colors::*;
use crate::notify::notify;

use apt_cmd::AptUpgradeEvent;
use chrono::{TimeZone, Utc};
use clap::ArgMatches;
use fomat_macros::{fomat, pintln};
use num_traits::FromPrimitive;
use pop_upgrade::{
client,
Expand Down Expand Up @@ -38,7 +38,7 @@ const UPGRADE_RESULT_STR: &str = "Release upgrade status";
const UPGRADE_RESULT_SUCCESS: &str = "systems are go for launch: reboot now";
const UPGRADE_RESULT_ERROR: &str = "release upgrade aborted";

#[derive(Shrinkwrap)]
#[derive(shrinkwraprs::Shrinkwrap)]
pub struct Client(client::Client);

impl Client {
Expand Down Expand Up @@ -235,7 +235,7 @@ impl Client {
/// Check if the release has been dismissed by timestamp, or can be.
fn dismiss_by_timestamp(&self, next: &str) -> Result<bool, client::Error> {
if !Path::new(INSTALL_DATE).exists() && installed_after_release(next) {
info!("dismissing notification for the latest release automatically");
log::info!("dismissing notification for the latest release automatically");
let _ = self.dismiss_notification(DismissEvent::ByTimestamp)?;
Ok(true)
} else {
Expand Down Expand Up @@ -294,7 +294,7 @@ impl Client {
if let Ok(event) = AptUpgradeEvent::from_dbus_map(event.into_iter()) {
write_apt_event(event);
} else {
error!("failed to unpack the upgrade event");
log::error!("failed to unpack the upgrade event");
}
}
_ => (),
Expand Down Expand Up @@ -412,7 +412,9 @@ impl Client {
client::Signal::PackageUpgrade(event) => {
match AptUpgradeEvent::from_dbus_map(event.clone().into_iter()) {
Ok(event) => write_apt_event(event),
Err(()) => error!("failed to unpack the upgrade event: {:?}", event),
Err(()) => {
log::error!("failed to unpack the upgrade event: {:?}", event)
}
}
}
client::Signal::ReleaseResult(status) => {
Expand Down Expand Up @@ -481,18 +483,19 @@ fn installed_after_release(next: &str) -> bool {
Ok(codename) => {
return codename.release_timestamp() < install_time as u64
}
Err(()) => error!("version {} is invalid", next),
Err(()) => log::error!("version {} is invalid", next),
}
}
_ => error!(
_ => log::error!(
"major ({}) and minor({}) version failed to parse as u8",
major, minor
major,
minor
),
}
}
None => error!("version {} is invalid", next),
None => log::error!("version {} is invalid", next),
},
Err(why) => error!("failed to get install time: {}", why),
Err(why) => log::error!("failed to get install time: {}", why),
}

false
Expand Down Expand Up @@ -525,7 +528,7 @@ fn notification_message(current: &str, next: &str) -> (String, String) {
}
EolStatus::Ok => (),
},
Err(why) => error!("failed to fetch EOL date: {}", why),
Err(why) => log::error!("failed to fetch EOL date: {}", why),
}

("Upgrade Available".into(), fomat!("Pop!_OS " (next) " is available to download"))
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/dbus_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'a> DbusFactory<'a> {
Ok(vec![mret])
}
Err(why) => {
error!("{}", why);
log::error!("{}", why);
Err(MethodErr::failed(&why))
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/daemon/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dbus::{
};

use crate::misc::format_error;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::atomic::Ordering};

Expand Down Expand Up @@ -213,7 +214,7 @@ pub fn refresh_os(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory) -> Me
_ => RefreshOp::Status,
})?;

info!("responding with value of {}", value);
log::info!("responding with value of {}", value);

Ok(vec![value.into()])
});
Expand Down
Loading

0 comments on commit 9cd01d3

Please sign in to comment.