Skip to content

Commit

Permalink
Normalize Log Message Strings
Browse files Browse the repository at this point in the history
The general style for errors, warnings and info messages is to start
with a capitalized letter and end without a period. The main exception
is when dealing with nouns that are clearer with special case handling,
e.g. "macOS failed to work" or "ioctl is borked".
  • Loading branch information
nixpulvis authored and chrisduerr committed Jan 7, 2019
1 parent dfc30ee commit 04707cb
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 192 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Log messages are now consistent in style, and some have been removed
- Windows configuration location has been moved from %USERPROFILE%\alacritty.yml
to %APPDATA%\alacritty\alacritty.yml
- Windows default shell is now PowerShell instead of cmd
Expand Down
2 changes: 1 addition & 1 deletion copypasta/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum Error {
impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::Clipboard(..) => "error opening clipboard",
Error::Clipboard(..) => "Error opening clipboard",
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions copypasta/src/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ impl ::std::error::Error for Error {

fn description(&self) -> &str {
match *self {
Error::Io(..) => "error calling xclip",
Error::Xclip(..) => "error reported by xclip",
Error::Utf8(..) => "clipboard contents not utf8",
Error::Io(..) => "Error calling xclip",
Error::Xclip(..) => "Error reported by xclip",
Error::Utf8(..) => "Clipboard contents not utf8",
}
}
}
Expand All @@ -50,11 +50,11 @@ impl ::std::fmt::Display for Error {
io::ErrorKind::NotFound => {
write!(f, "Please install `xclip` to enable clipboard support")
},
_ => write!(f, "error calling xclip: {}", err),
_ => write!(f, "Error calling xclip: {}", err),
}
},
Error::Xclip(ref s) => write!(f, "error from xclip: {}", s),
Error::Utf8(ref err) => write!(f, "error parsing xclip output: {}", err),
Error::Xclip(ref s) => write!(f, "Error from xclip: {}", s),
Error::Utf8(ref err) => write!(f, "Error parsing xclip output: {}", err),
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions font/src/darwin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ pub enum Error {
impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::MissingGlyph(ref _c) => "couldn't find the requested glyph",
Error::MissingFont(ref _desc) => "couldn't find the requested font",
Error::FontNotLoaded => "tried to operate on font that hasn't been loaded",
Error::MissingGlyph(ref _c) => "Couldn't find the requested glyph",
Error::MissingFont(ref _desc) => "Couldn't find the requested font",
Error::FontNotLoaded => "Tried to operate on font that hasn't been loaded",
}
}
}
Expand All @@ -129,7 +129,6 @@ impl ::Rasterize for Rasterizer {
type Err = Error;

fn new(device_pixel_ratio: f32, use_thin_strokes: bool) -> Result<Rasterizer, Error> {
info!("device_pixel_ratio: {}", device_pixel_ratio);
Ok(Rasterizer {
fonts: HashMap::new(),
keys: HashMap::new(),
Expand Down Expand Up @@ -332,7 +331,7 @@ fn cascade_list_for_languages(
pub fn descriptors_for_family(family: &str) -> Vec<Descriptor> {
let mut out = Vec::new();

info!("family: {}", family);
trace!("Family: {}", family);
let ct_collection = match create_for_family(family) {
Some(c) => c,
None => return out,
Expand Down Expand Up @@ -627,7 +626,7 @@ mod tests {
fn get_descriptors_and_build_font() {
let list = super::descriptors_for_family("Menlo");
assert!(!list.is_empty());
info!("{:?}", list);
println!("{:?}", list);

// Check to_font
let fonts = list.iter()
Expand Down
4 changes: 2 additions & 2 deletions font/src/ft/fc/font_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'a> IntoIterator for &'a FontSet {
(*self.as_ptr()).nfont as isize
};

info!("num fonts = {}", num_fonts);
trace!("Number of fonts is {}", num_fonts);

Iter {
font_set: self.deref(),
Expand All @@ -81,7 +81,7 @@ impl<'a> IntoIterator for &'a FontSetRef {
(*self.as_ptr()).nfont as isize
};

info!("num fonts = {}", num_fonts);
trace!("Number of fonts is {}", num_fonts);

Iter {
font_set: self,
Expand Down
14 changes: 7 additions & 7 deletions font/src/ft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl ::Rasterize for FreeTypeRasterizer {
},
_ => {
// Fallback if font doesn't provide info about strikeout
trace!("No strikeout data available for font, using fallback.");
trace!("Using fallback strikeout metrics");
let strikeout_position = height as f32 / 2. + descent;
(strikeout_position, underline_thickness)
},
Expand Down Expand Up @@ -267,7 +267,7 @@ impl FreeTypeRasterizer {
return Ok(Some(*key));
}

trace!("got font path={:?}", path);
trace!("Got font path={:?}", path);
let ft_face = self.library.new_face(&path, index)?;

// Get available pixel sizes if font isn't scalable.
Expand Down Expand Up @@ -550,12 +550,12 @@ impl FreeTypeRasterizer {
// We've previously loaded this font, so don't
// load it again.
Some(&key) => {
debug!("Hit for font {:?}; no need to load.", path);
debug!("Hit for font {:?}; no need to load", path);
Ok(key)
},

None => {
debug!("Miss for font {:?}; loading now.", path);
debug!("Miss for font {:?}; loading now", path);
// Safe to unwrap the option since we've already checked for the path
// and index above.
let key = self.face_from_pattern(&pattern)?.unwrap();
Expand Down Expand Up @@ -604,9 +604,9 @@ impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::FreeType(ref err) => err.description(),
Error::MissingFont(ref _desc) => "couldn't find the requested font",
Error::FontNotLoaded => "tried to operate on font that hasn't been loaded",
Error::MissingSizeMetrics => "tried to get size metrics from a face without a size",
Error::MissingFont(ref _desc) => "Couldn't find the requested font",
Error::FontNotLoaded => "Tried to operate on font that hasn't been loaded",
Error::MissingSizeMetrics => "Tried to get size metrics from a face without a size",
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion font/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl FontDesc {

impl fmt::Display for FontDesc {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "name '{}' and style '{}'", self.name, self.style)
write!(f, "name {} and style {}", self.name, self.style)
}
}

Expand Down
8 changes: 4 additions & 4 deletions font/src/rusttype/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ pub enum Error {
impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::MissingFont(ref _desc) => "couldn't find the requested font",
Error::UnsupportedFont => "only TrueType fonts are supported",
Error::UnsupportedStyle => "the selected style is not supported by rusttype",
Error::MissingGlyph => "the selected font did not have the requested glyph",
Error::MissingFont(ref _desc) => "Couldn't find the requested font",
Error::UnsupportedFont => "Only TrueType fonts are supported",
Error::UnsupportedStyle => "The selected style is not supported by rusttype",
Error::MissingGlyph => "The selected font does not have the requested glyph",
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ansi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ impl Mode {
1049 => Mode::SwapScreenAndSetRestoreCursor,
2004 => Mode::BracketedPaste,
_ => {
trace!("[unhandled] mode={:?}", num);
trace!("[unimplemented] primitive mode: {}", num);
return None
}
})
Expand Down
Loading

0 comments on commit 04707cb

Please sign in to comment.