Normalize Log Message Strings

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".
This commit is contained in:
Nathan Lilienthal 2019-01-06 19:06:57 -05:00 committed by Christian Duerr
parent dfc30eeef5
commit 04707cbba6
21 changed files with 197 additions and 192 deletions

View File

@ -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

View File

@ -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",
}
}
}

View File

@ -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",
}
}
}
@ -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),
}
}
}

View File

@ -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",
}
}
}
@ -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(),
@ -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,
@ -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()

View File

@ -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(),
@ -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,

View File

@ -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)
},
@ -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.
@ -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();
@ -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",
}
}
}

View File

@ -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)
}
}

View File

@ -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",
}
}
}

View File

@ -445,7 +445,7 @@ impl Mode {
1049 => Mode::SwapScreenAndSetRestoreCursor,
2004 => Mode::BracketedPaste,
_ => {
trace!("[unhandled] mode={:?}", num);
trace!("[unimplemented] primitive mode: {}", num);
return None
}
})

View File

@ -73,7 +73,7 @@ fn deserialize_duration_ms<'a, D>(deserializer: D) -> ::std::result::Result<Dura
match u64::deserialize(deserializer) {
Ok(threshold_ms) => Ok(Duration::from_millis(threshold_ms)),
Err(err) => {
error!("problem with config: {}; Using default value", err);
error!("Problem with config: {}; using default value", err);
Ok(default_threshold_ms())
},
}
@ -171,7 +171,7 @@ fn deserialize_visual_bell_duration<'a, D>(deserializer: D) -> ::std::result::Re
match u16::deserialize(deserializer) {
Ok(duration) => Ok(duration),
Err(err) => {
error!("problem with config: {}; Using default value", err);
error!("Problem with config: {}; using default value", err);
Ok(0)
},
}
@ -320,19 +320,19 @@ impl<'de> Deserialize<'de> for Decorations {
"none" => Ok(Decorations::None),
"full" => Ok(Decorations::Full),
"true" => {
error!("deprecated decorations boolean value, \
error!("Deprecated decorations boolean value, \
use one of transparent|buttonless|none|full instead; \
Falling back to \"full\"");
falling back to \"full\"");
Ok(Decorations::Full)
},
"false" => {
error!("deprecated decorations boolean value, \
error!("Deprecated decorations boolean value, \
use one of transparent|buttonless|none|full instead; \
Falling back to \"none\"");
falling back to \"none\"");
Ok(Decorations::None)
},
_ => {
error!("invalid decorations value: {}; Using default value", value);
error!("Invalid decorations value: {}; using default value", value);
Ok(Decorations::Full)
}
}
@ -346,23 +346,23 @@ impl<'de> Deserialize<'de> for Decorations {
"none" => Ok(Decorations::None),
"full" => Ok(Decorations::Full),
"true" => {
error!("deprecated decorations boolean value, \
error!("Deprecated decorations boolean value, \
use one of none|full instead; \
Falling back to \"full\"");
falling back to \"full\"");
Ok(Decorations::Full)
},
"false" => {
error!("deprecated decorations boolean value, \
error!("Deprecated decorations boolean value, \
use one of none|full instead; \
Falling back to \"none\"");
falling back to \"none\"");
Ok(Decorations::None)
},
"transparent" | "buttonless" => {
error!("macos-only decorations value: {}; Using default value", value);
error!("macOS-only decorations value: {}; using default value", value);
Ok(Decorations::Full)
},
_ => {
error!("invalid decorations value: {}; Using default value", value);
error!("Invalid decorations value: {}; using default value", value);
Ok(Decorations::Full)
}
}
@ -406,7 +406,7 @@ fn deserialize_padding<'a, D>(deserializer: D) -> ::std::result::Result<Delta<u8
match Delta::deserialize(deserializer) {
Ok(delta) => Ok(delta),
Err(err) => {
error!("problem with config: {}; Using default value", err);
error!("Problem with config: {}; using default value", err);
Ok(default_padding())
},
}
@ -557,7 +557,7 @@ fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T
let vec = match Vec::<serde_yaml::Value>::deserialize(deserializer) {
Ok(vec) => vec,
Err(err) => {
error!("problem with config: {}; Using empty vector", err);
error!("Problem with config: {}; using empty vector", err);
return Ok(Vec::new());
},
};
@ -568,7 +568,7 @@ fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T
match T::deserialize(value) {
Ok(binding) => bindings.push(binding),
Err(err) => {
error!("problem with config: {}; Skipping value", err);
error!("Problem with config: {}; skipping value", err);
},
}
}
@ -586,7 +586,7 @@ fn deserialize_tabspaces<'a, D>(deserializer: D) -> ::std::result::Result<usize,
match usize::deserialize(deserializer) {
Ok(value) => Ok(value),
Err(err) => {
error!("problem with config: {}; Using `8`", err);
error!("Problem with config: {}; using 8", err);
Ok(default_tabspaces())
},
}
@ -598,7 +598,7 @@ fn default_true_bool<'a, D>(deserializer: D) -> ::std::result::Result<bool, D::E
match bool::deserialize(deserializer) {
Ok(value) => Ok(value),
Err(err) => {
error!("problem with config: {}; Using `true`", err);
error!("Problem with config: {}; using true", err);
Ok(true)
},
}
@ -612,7 +612,7 @@ fn failure_default<'a, D, T>(deserializer: D)
match T::deserialize(deserializer) {
Ok(value) => Ok(value),
Err(err) => {
error!("problem with config: {}; Using default value", err);
error!("Problem with config: {}; using default value", err);
Ok(T::default())
},
}
@ -675,8 +675,8 @@ fn deserialize_scrolling_history<'a, D>(deserializer: D) -> ::std::result::Resul
Ok(lines) => {
if lines > MAX_SCROLLBACK_LINES {
error!(
"problem with config: scrollback size is {}, but expected a maximum of {}; \
Using {1} instead",
"Problem with config: scrollback size is {}, but expected a maximum of {}; \
using {1} instead",
lines, MAX_SCROLLBACK_LINES,
);
Ok(MAX_SCROLLBACK_LINES)
@ -685,7 +685,7 @@ fn deserialize_scrolling_history<'a, D>(deserializer: D) -> ::std::result::Resul
}
},
Err(err) => {
error!("problem with config: {}; Using default value", err);
error!("Problem with config: {}; using default value", err);
Ok(default_scrolling_history())
},
}
@ -697,7 +697,7 @@ fn deserialize_scrolling_multiplier<'a, D>(deserializer: D) -> ::std::result::Re
match u8::deserialize(deserializer) {
Ok(lines) => Ok(lines),
Err(err) => {
error!("problem with config: {}; Using default value", err);
error!("Problem with config: {}; using default value", err);
Ok(default_scrolling_multiplier())
},
}
@ -739,7 +739,7 @@ impl<'a> de::Deserialize<'a> for ModsWrapper {
"Shift" => res.shift = true,
"Alt" | "Option" => res.alt = true,
"Control" => res.ctrl = true,
_ => error!("unknown modifier {:?}", modifier),
_ => error!("Unknown modifier {:?}", modifier),
}
}
@ -862,7 +862,7 @@ impl<'a> de::Deserialize<'a> for ModeWrapper {
"~AppCursor" => res.not_mode |= mode::TermMode::APP_CURSOR,
"AppKeypad" => res.mode |= mode::TermMode::APP_KEYPAD,
"~AppKeypad" => res.not_mode |= mode::TermMode::APP_KEYPAD,
_ => error!("unknown mode {:?}", modifier),
_ => error!("Unknown mode {:?}", modifier),
}
}
@ -1045,7 +1045,7 @@ impl<'a> de::Deserialize<'a> for RawBinding {
let scancode = val.as_u64().unwrap();
if scancode > u64::from(::std::u32::MAX) {
return Err(<V::Error as Error>::custom(format!(
"invalid key binding, scancode too big: {}",
"Invalid key binding, scancode too big: {}",
scancode
)));
}
@ -1225,9 +1225,9 @@ fn deserialize_color_index<'a, D>(deserializer: D) -> ::std::result::Result<u8,
Ok(index) => {
if index < 16 {
error!(
"problem with config: indexed_color's index is '{}', \
"Problem with config: indexed_color's index is {}, \
but a value bigger than 15 was expected; \
Ignoring setting",
ignoring setting",
index
);
@ -1238,7 +1238,7 @@ fn deserialize_color_index<'a, D>(deserializer: D) -> ::std::result::Result<u8,
}
},
Err(err) => {
error!("problem with config: {}; Ignoring setting", err);
error!("Problem with config: {}; ignoring setting", err);
// Return value out of range to ignore this color
Ok(0)
@ -1293,7 +1293,7 @@ fn deserialize_optional_color<'a, D>(deserializer: D) -> ::std::result::Result<O
},
Ok(None) => Ok(None),
Err(err) => {
error!("problem with config: {}; Using standard foreground color", err);
error!("Problem with config: {}; using standard foreground color", err);
Ok(None)
},
}
@ -1375,14 +1375,14 @@ fn rgb_from_hex<'a, D>(deserializer: D) -> ::std::result::Result<Rgb, D::Error>
type Value = Rgb;
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Hex colors spec like 'ffaabb'")
f.write_str("hex color like 0xff00ff")
}
fn visit_str<E>(self, value: &str) -> ::std::result::Result<Rgb, E>
where E: ::serde::de::Error
{
Rgb::from_str(&value[..])
.map_err(|_| E::custom("failed to parse rgb; expect 0xrrggbb"))
.map_err(|_| E::custom("failed to parse rgb; expected hex color like 0xff00ff"))
}
}
@ -1392,7 +1392,7 @@ fn rgb_from_hex<'a, D>(deserializer: D) -> ::std::result::Result<Rgb, D::Error>
match rgb {
Ok(rgb) => Ok(rgb),
Err(err) => {
error!("problem with config: {}; Using color #ff00ff", err);
error!("Problem with config: {}; using color #ff00ff", err);
Ok(Rgb { r: 255, g: 0, b: 255 })
},
}
@ -1444,8 +1444,8 @@ impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::NotFound => "could not locate config file",
Error::Empty => "empty config file",
Error::NotFound => "Couldn't locate config file",
Error::Empty => "Empty config file",
Error::ReadingEnvHome(ref err) => err.description(),
Error::Io(ref err) => err.description(),
Error::Yaml(ref err) => err.description(),
@ -1458,10 +1458,10 @@ impl ::std::fmt::Display for Error {
match *self {
Error::NotFound | Error::Empty => write!(f, "{}", ::std::error::Error::description(self)),
Error::ReadingEnvHome(ref err) => {
write!(f, "could not read $HOME environment variable: {}", err)
write!(f, "Couldn't read $HOME environment variable: {}", err)
},
Error::Io(ref err) => write!(f, "error reading config file: {}", err),
Error::Yaml(ref err) => write!(f, "problem with config: {}", err),
Error::Io(ref err) => write!(f, "Error reading config file: {}", err),
Error::Yaml(ref err) => write!(f, "Problem with config: {}", err),
}
}
}
@ -1538,7 +1538,7 @@ impl Config {
if let Some(old_path) = old.as_ref().filter(|old| old.exists()) {
warn!(
"Found configuration at: '{}'. The file should be moved to the new location: '{}'.",
"Found configuration at: {}; this file should be moved to the new location: {}",
old_path.to_string_lossy(),
new.as_ref().map(|new| new.to_string_lossy()).unwrap(),
);
@ -1564,7 +1564,7 @@ impl Config {
pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
let mut path = dirs::config_dir()
.ok_or_else(|| {
io::Error::new(io::ErrorKind::NotFound, "could not find profile directory")
io::Error::new(io::ErrorKind::NotFound, "Couldn't find profile directory")
}
)?;
@ -1765,21 +1765,22 @@ impl Config {
fn print_deprecation_warnings(&mut self) {
if self.dimensions.is_some() {
warn!("{}", "Config `dimensions` is deprecated. \
Please use `window.dimensions` instead.");
warn!("Config dimensions is deprecated; \
please use window.dimensions instead");
}
if self.padding.is_some() {
warn!("{}", "Config `padding` is deprecated. Please use `window.padding` instead.");
warn!("Config padding is deprecated; \
please use window.padding instead");
}
if self.mouse.faux_scrollback_lines.is_some() {
warn!("{}", "Config `mouse.faux_scrollback_lines` is deprecated. \
Please use `mouse.faux_scrolling_lines` instead.");
warn!("Config mouse.faux_scrollback_lines is deprecated; \
please use mouse.faux_scrolling_lines instead");
}
if let Some(custom_cursor_colors) = self.custom_cursor_colors {
warn!("{}", "Config `custom_cursor_colors` is deprecated.");
warn!("Config custom_cursor_colors is deprecated");
if !custom_cursor_colors {
self.colors.cursor.cursor = None;
@ -1788,17 +1789,18 @@ impl Config {
}
if self.cursor_style.is_some() {
warn!("{}", "Config `cursor_style` is deprecated. Please use `cursor.style` instead.");
warn!("Config cursor_style is deprecated; \
please use cursor.style instead");
}
if self.hide_cursor_when_typing.is_some() {
warn!("{}", "Config `hide_cursor_when_typing` is deprecated. \
Please use `mouse.hide_when_typing` instead.");
warn!("Config hide_cursor_when_typing is deprecated; \
please use mouse.hide_when_typing instead");
}
if self.unfocused_hollow_cursor.is_some() {
warn!("{}", "Config `unfocused_hollow_cursor` is deprecated. \
Please use `cursor.unfocused_hollow` instead.");
warn!("Config unfocused_hollow_cursor is deprecated; \
please use cursor.unfocused_hollow instead");
}
}
}
@ -1899,7 +1901,7 @@ impl DeserializeSize for Size {
match size {
Ok(size) => Ok(size),
Err(err) => {
error!("problem with config: {}; Using size 12", err);
error!("Problem with config: {}; using size 12", err);
Ok(Size::new(12.))
},
}
@ -1949,7 +1951,7 @@ where
{
// This is necessary in order to get serde to complete deserialization of the configuration
let _ignored = bool::deserialize(deserializer);
error!("The `scale_with_dpi` setting has been removed, \
error!("The scale_with_dpi setting has been removed, \
on X11 the WINIT_HIDPI_FACTOR environment variable can be used instead.");
Ok(None)
}

View File

@ -144,7 +144,7 @@ impl Display {
let mut window = Window::new(&options, config.window())?;
let dpr = window.hidpi_factor();
info!("device_pixel_ratio: {}", dpr);
info!("Device pixel ratio: {}", dpr);
// get window properties for initializing the other subsystems
let mut viewport_size = window.inner_size_pixels()
@ -241,15 +241,16 @@ impl Display {
// Initialize glyph cache
let glyph_cache = {
info!("Initializing glyph cache");
info!("Initializing glyph cache...");
let init_start = ::std::time::Instant::now();
let cache =
renderer.with_loader(|mut api| GlyphCache::new(rasterizer, &font, &mut api))?;
let stop = init_start.elapsed();
let stop_f = stop.as_secs() as f64 + f64::from(stop.subsec_nanos()) / 1_000_000_000f64;
info!("Finished initializing glyph cache in {}", stop_f);
let stop_f = stop.as_secs() as f64 +
f64::from(stop.subsec_nanos()) / 1_000_000_000f64;
info!("... finished initializing glyph cache in {}s", stop_f);
cache
};

View File

@ -385,10 +385,10 @@ impl<T> EventLoop<T>
if let Err(err) = self.pty_read(&mut state, &mut buf, pipe.as_mut())
{
error!(
"Event loop exitting due to error: {} [{}:{}]",
err,
"[{}:{}] Event loop exiting due to error: {}",
file!(),
line!()
line!(),
err
);
break 'event_loop;
}
@ -401,10 +401,10 @@ impl<T> EventLoop<T>
if event.readiness().is_writable() {
if let Err(err) = self.pty_write(&mut state) {
error!(
"Event loop exitting due to error: {} [{}:{}]",
err,
"[{}:{}] Event loop exiting due to error: {}",
file!(),
line!()
line!(),
err
);
break 'event_loop;
}

View File

@ -84,8 +84,6 @@ fn scroll_down() {
// Test that GridIterator works
#[test]
fn test_iter() {
info!("");
let mut grid = Grid::new(Line(5), Column(5), 0, 0);
for i in 0..5 {
for j in 0..5 {
@ -93,8 +91,6 @@ fn test_iter() {
}
}
info!("grid: {:?}", grid);
let mut iter = grid.iter_from(Point {
line: 4,
col: Column(0),

View File

@ -224,7 +224,7 @@ impl Action {
.and_then(|clipboard| clipboard.load_primary() )
.map(|contents| { self.paste(ctx, &contents) })
.unwrap_or_else(|err| {
error!("Error loading data from clipboard. {}", Red(err));
error!("Error loading data from clipboard: {}", Red(err));
});
},
Action::PasteSelection => {
@ -234,19 +234,19 @@ impl Action {
.and_then(|clipboard| clipboard.load_selection() )
.map(|contents| { self.paste(ctx, &contents) })
.unwrap_or_else(|err| {
error!("Error loading data from clipboard. {}", Red(err));
error!("Error loading data from clipboard: {}", Red(err));
});
}
},
Action::Command(ref program, ref args) => {
trace!("running command: {} {:?}", program, args);
trace!("Running command {} with args {:?}", program, args);
match start_daemon(program, args) {
Ok(_) => {
debug!("spawned new proc");
debug!("Spawned new proc");
},
Err(err) => {
warn!("couldn't run command: {}", err);
warn!("Couldn't run command {}", err);
},
}
},
@ -546,8 +546,8 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
args.push(text);
match start_daemon(launcher.program(), &args) {
Ok(_) => debug!("Launched: {} {:?}", launcher.program(), args),
Err(_) => warn!("Unable to launch: {} {:?}", launcher.program(), args),
Ok(_) => debug!("Launched {} with args {:?}", launcher.program(), args),
Err(_) => warn!("Unable to launch {} with args {:?}", launcher.program(), args),
}
Some(())

View File

@ -125,13 +125,26 @@ impl log::Log for Logger {
}
fn log(&self, record: &log::Record<'_>) {
if self.enabled(record.metadata()) && record.target().starts_with("alacritty") {
let msg = format!(
"[{}] [{}] {}\n",
time::now().strftime("%F %R").unwrap(),
record.level(),
record.args()
);
if self.enabled(record.metadata()) &&
record.target().starts_with("alacritty")
{
let now = time::strftime("%F %R", &time::now()).unwrap();
let msg = if record.level() >= Level::Trace {
format!("[{}] [{}] [{}:{}] {}\n",
now,
record.level(),
record.file().unwrap_or("?"),
record.line()
.map(|l| l.to_string())
.unwrap_or("?".to_string()),
record.args())
} else {
format!("[{}] [{}] {}\n",
now,
record.level(),
record.args())
};
if let Ok(ref mut logfile) = self.logfile.lock() {
let _ = logfile.write_all(msg.as_ref());

View File

@ -99,8 +99,8 @@ fn load_config(options: &cli::Options) -> Config {
Config::load_from(&*config_path).unwrap_or_else(|err| {
match err {
ConfigError::Empty => info!("Config file {:?} is empty; Loading default", config_path),
_ => error!("Error: {}; Loading default config", err),
ConfigError::Empty => info!("Config file {:?} is empty; loading default", config_path),
_ => error!("Error: {}; loading default config", err),
}
Config::default()
@ -116,9 +116,9 @@ fn run(
options: &cli::Options,
mut logger_proxy: LoggerProxy,
) -> Result<(), Box<dyn Error>> {
info!("Welcome to Alacritty.");
info!("Welcome to Alacritty");
if let Some(config_path) = config.path() {
info!("Configuration loaded from {}", config_path.display());
info!("Configuration loaded from {:?}", config_path.display());
};
// Set environment variables
@ -264,7 +264,7 @@ fn run(
#[cfg(windows)]
unsafe { FreeConsole(); }
info!("Goodbye.");
info!("Goodbye");
if !options.persistent_logging && !config.persistent_logging() {
logger_proxy.delete_log();

View File

@ -321,7 +321,7 @@ impl GlyphCache {
self.rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size() })?;
let metrics = self.rasterizer.metrics(regular, size)?;
info!("Font size changed: {:?} [DPR: {}]", font.size, dpr);
info!("Font size changed to {:?} with DPR of {}", font.size, dpr);
self.font_size = font.size;
self.font_key = regular;
@ -816,26 +816,15 @@ impl QuadRenderer {
}
pub fn reload_shaders(&mut self, size: PhysicalSize) {
warn!("Reloading shaders ...");
warn!("Reloading shaders...");
let result = (TextShaderProgram::new(size), RectShaderProgram::new());
let (program, rect_program) = match result {
(Ok(program), Ok(rect_program)) => {
warn!(" ... OK");
info!("... successfully reloaded shaders");
(program, rect_program)
}
(Err(err), _) | (_, Err(err)) => {
match err {
ShaderCreationError::Io(err) => {
error!("Error reading shader file: {}", err);
}
ShaderCreationError::Compile(path, log) => {
error!("Error compiling shader at {:?}\n{}", path, log);
}
ShaderCreationError::Link(log) => {
error!("Error reloading shaders: {}", log);
}
}
error!("{}", err);
return;
}
};
@ -1234,7 +1223,7 @@ impl TextShaderProgram {
);
let projection: [[f32; 4]; 4] = ortho.into();
info!("width: {}, height: {}", width, height);
info!("Width: {}, Height: {}", width, height);
unsafe {
gl::UniformMatrix4fv(
@ -1483,11 +1472,15 @@ impl ::std::error::Error for ShaderCreationError {
impl ::std::fmt::Display for ShaderCreationError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
ShaderCreationError::Io(ref err) => write!(f, "couldn't read shader: {}", err),
ShaderCreationError::Compile(ref _path, ref s) => {
write!(f, "failed compiling shader: {}", s)
}
ShaderCreationError::Link(ref s) => write!(f, "failed linking shader: {}", s),
ShaderCreationError::Io(ref err) => {
write!(f, "Couldn't read shader: {}", err)
},
ShaderCreationError::Compile(ref path, ref log) => {
write!(f, "Failed compiling shader at {}: {}", path.display(), log)
},
ShaderCreationError::Link(ref log) => {
write!(f, "Failed linking shader: {}", log)
},
}
}
}

View File

@ -1167,7 +1167,7 @@ impl Term {
/// Resize terminal to new dimensions
pub fn resize(&mut self, size : &SizeInfo) {
debug!("Term::resize");
debug!("Resizing terminal");
// Bounds check; lots of math assumes width and height are > 0
if size.width as usize <= 2 * self.size_info.padding_x as usize ||
@ -1224,7 +1224,7 @@ impl Term {
}
}
debug!("num_cols, num_lines = {}, {}", num_cols, num_lines);
debug!("New num_cols is {} and num_lines is {}", num_cols, num_lines);
// Resize grids to new size
self.grid.resize(num_lines, num_cols, &Cell::default());
@ -1276,7 +1276,7 @@ impl Term {
/// Expects origin to be in scroll range.
#[inline]
fn scroll_down_relative(&mut self, origin: Line, mut lines: Line) {
trace!("scroll_down_relative: origin={}, lines={}", origin, lines);
trace!("Scrolling down relative: origin={}, lines={}", origin, lines);
lines = min(lines, self.scroll_region.end - self.scroll_region.start);
lines = min(lines, self.scroll_region.end - origin);
@ -1290,7 +1290,7 @@ impl Term {
/// Expects origin to be in scroll range.
#[inline]
fn scroll_up_relative(&mut self, origin: Line, lines: Line) {
trace!("scroll_up_relative: origin={}, lines={}", origin, lines);
trace!("Scrolling up relative: origin={}, lines={}", origin, lines);
let lines = min(lines, self.scroll_region.end - self.scroll_region.start);
// Scroll from origin to bottom less number of lines
@ -1354,7 +1354,7 @@ impl ansi::Handler for Term {
return;
}
trace!("wrapping");
trace!("Wrapping input");
{
let location = Point {
@ -1434,7 +1434,7 @@ impl ansi::Handler for Term {
#[inline]
fn dectest(&mut self) {
trace!("dectest");
trace!("Dectesting");
let mut template = self.cursor.template;
template.c = 'E';
@ -1444,7 +1444,7 @@ impl ansi::Handler for Term {
#[inline]
fn goto(&mut self, line: Line, col: Column) {
trace!("goto: line={}, col={}", line, col);
trace!("Going to: line={}, col={}", line, col);
let (y_offset, max_y) = if self.mode.contains(mode::TermMode::ORIGIN) {
(self.scroll_region.start, self.scroll_region.end - 1)
} else {
@ -1458,13 +1458,13 @@ impl ansi::Handler for Term {
#[inline]
fn goto_line(&mut self, line: Line) {
trace!("goto_line: {}", line);
trace!("Going to line: {}", line);
self.goto(line, self.cursor.point.col)
}
#[inline]
fn goto_col(&mut self, col: Column) {
trace!("goto_col: {}", col);
trace!("Going to column: {}", col);
self.goto(self.cursor.point.line, col)
}
@ -1497,28 +1497,28 @@ impl ansi::Handler for Term {
#[inline]
fn move_up(&mut self, lines: Line) {
trace!("move_up: {}", lines);
trace!("Moving up: {}", lines);
let move_to = Line(self.cursor.point.line.0.saturating_sub(lines.0));
self.goto(move_to, self.cursor.point.col)
}
#[inline]
fn move_down(&mut self, lines: Line) {
trace!("move_down: {}", lines);
trace!("Moving down: {}", lines);
let move_to = self.cursor.point.line + lines;
self.goto(move_to, self.cursor.point.col)
}
#[inline]
fn move_forward(&mut self, cols: Column) {
trace!("move_forward: {}", cols);
trace!("Moving forward: {}", cols);
self.cursor.point.col = min(self.cursor.point.col + cols, self.grid.num_cols() - 1);
self.input_needs_wrap = false;
}
#[inline]
fn move_backward(&mut self, cols: Column) {
trace!("move_backward: {}", cols);
trace!("Moving backward: {}", cols);
self.cursor.point.col -= min(self.cursor.point.col, cols);
self.input_needs_wrap = false;
}
@ -1530,7 +1530,7 @@ impl ansi::Handler for Term {
#[inline]
fn device_status<W: io::Write>(&mut self, writer: &mut W, arg: usize) {
trace!("device status: {}", arg);
trace!("Reporting device status: {}", arg);
match arg {
5 => {
let _ = writer.write_all(b"\x1b[0n");
@ -1545,21 +1545,21 @@ impl ansi::Handler for Term {
#[inline]
fn move_down_and_cr(&mut self, lines: Line) {
trace!("move_down_and_cr: {}", lines);
trace!("Moving down and cr: {}", lines);
let move_to = self.cursor.point.line + lines;
self.goto(move_to, Column(0))
}
#[inline]
fn move_up_and_cr(&mut self, lines: Line) {
trace!("move_up_and_cr: {}", lines);
trace!("Moving up and cr: {}", lines);
let move_to = Line(self.cursor.point.line.0.saturating_sub(lines.0));
self.goto(move_to, Column(0))
}
#[inline]
fn put_tab(&mut self, mut count: i64) {
trace!("put_tab: {}", count);
trace!("Putting tab: {}", count);
while self.cursor.point.col < self.grid.num_cols() && count != 0 {
count -= 1;
@ -1587,7 +1587,7 @@ impl ansi::Handler for Term {
/// Backspace `count` characters
#[inline]
fn backspace(&mut self) {
trace!("backspace");
trace!("Backspace");
if self.cursor.point.col > Column(0) {
self.cursor.point.col -= 1;
self.input_needs_wrap = false;
@ -1597,7 +1597,7 @@ impl ansi::Handler for Term {
/// Carriage return
#[inline]
fn carriage_return(&mut self) {
trace!("carriage_return");
trace!("Carriage return");
self.cursor.point.col = Column(0);
self.input_needs_wrap = false;
}
@ -1605,7 +1605,7 @@ impl ansi::Handler for Term {
/// Linefeed
#[inline]
fn linefeed(&mut self) {
trace!("linefeed");
trace!("Linefeed");
let next = self.cursor.point.line + 1;
if next == self.scroll_region.end {
self.scroll_up(Line(1));
@ -1617,14 +1617,14 @@ impl ansi::Handler for Term {
/// Set current position as a tabstop
#[inline]
fn bell(&mut self) {
trace!("bell");
trace!("Bell");
self.visual_bell.ring();
self.next_is_urgent = Some(true);
}
#[inline]
fn substitute(&mut self) {
trace!("[unimplemented] substitute");
trace!("[unimplemented] Substitute");
}
/// Run LF/NL
@ -1660,7 +1660,7 @@ impl ansi::Handler for Term {
#[inline]
fn set_horizontal_tabstop(&mut self) {
trace!("set_horizontal_tabstop");
trace!("Setting horizontal tabstop");
let column = self.cursor.point.col;
self.tabs[column] = true;
}
@ -1679,7 +1679,7 @@ impl ansi::Handler for Term {
#[inline]
fn insert_blank_lines(&mut self, lines: Line) {
trace!("insert_blank_lines: {}", lines);
trace!("Inserting blank {} lines", lines);
if self.scroll_region.contains_(self.cursor.point.line) {
let origin = self.cursor.point.line;
self.scroll_down_relative(origin, lines);
@ -1688,7 +1688,7 @@ impl ansi::Handler for Term {
#[inline]
fn delete_lines(&mut self, lines: Line) {
trace!("delete_lines: {}", lines);
trace!("Deleting {} lines", lines);
if self.scroll_region.contains_(self.cursor.point.line) {
let origin = self.cursor.point.line;
self.scroll_up_relative(origin, lines);
@ -1697,7 +1697,7 @@ impl ansi::Handler for Term {
#[inline]
fn erase_chars(&mut self, count: Column) {
trace!("erase_chars: {}, {}", count, self.cursor.point.col);
trace!("Erasing chars: count={}, col={}", count, self.cursor.point.col);
let start = self.cursor.point.col;
let end = min(start + count, self.grid.num_cols() - 1);
@ -1737,7 +1737,7 @@ impl ansi::Handler for Term {
#[inline]
fn move_backward_tabs(&mut self, count: i64) {
trace!("move_backward_tabs: {}", count);
trace!("Moving backward {} tabs", count);
for _ in 0..count {
let mut col = self.cursor.point.col;
@ -1753,12 +1753,12 @@ impl ansi::Handler for Term {
#[inline]
fn move_forward_tabs(&mut self, count: i64) {
trace!("[unimplemented] move_forward_tabs: {}", count);
trace!("[unimplemented] Moving forward {} tabs", count);
}
#[inline]
fn save_cursor_position(&mut self) {
trace!("CursorSave");
trace!("Saving cursor position");
let cursor = if self.alt {
&mut self.cursor_save_alt
} else {
@ -1770,7 +1770,7 @@ impl ansi::Handler for Term {
#[inline]
fn restore_cursor_position(&mut self) {
trace!("CursorRestore");
trace!("Restoring cursor position");
let source = if self.alt {
&self.cursor_save_alt
} else {
@ -1784,7 +1784,7 @@ impl ansi::Handler for Term {
#[inline]
fn clear_line(&mut self, mode: ansi::LineClearMode) {
trace!("clear_line: {:?}", mode);
trace!("Clearing line: {:?}", mode);
let mut template = self.cursor.template;
template.flags ^= template.flags;
@ -1815,7 +1815,7 @@ impl ansi::Handler for Term {
/// Set the indexed color value
#[inline]
fn set_color(&mut self, index: usize, color: Rgb) {
trace!("set_color[{}] = {:?}", index, color);
trace!("Setting color[{}] = {:?}", index, color);
self.colors[index] = color;
self.color_modified[index] = true;
}
@ -1823,7 +1823,7 @@ impl ansi::Handler for Term {
/// Reset the indexed color to original value
#[inline]
fn reset_color(&mut self, index: usize) {
trace!("reset_color[{}]", index);
trace!("Reseting color[{}]", index);
self.colors[index] = self.original_colors[index];
self.color_modified[index] = false;
}
@ -1835,13 +1835,13 @@ impl ansi::Handler for Term {
Clipboard::new()
.and_then(|mut clipboard| clipboard.store_primary(string))
.unwrap_or_else(|err| {
warn!("Error storing selection to clipboard. {}", err);
warn!("Error storing selection to clipboard: {}", err);
});
}
#[inline]
fn clear_screen(&mut self, mode: ansi::ClearMode) {
trace!("clear_screen: {:?}", mode);
trace!("Clearing screen: {:?}", mode);
let mut template = self.cursor.template;
template.flags ^= template.flags;
@ -1881,7 +1881,7 @@ impl ansi::Handler for Term {
#[inline]
fn clear_tabs(&mut self, mode: ansi::TabulationClearMode) {
trace!("clear_tabs: {:?}", mode);
trace!("Clearing tabs: {:?}", mode);
match mode {
ansi::TabulationClearMode::Current => {
let column = self.cursor.point.col;
@ -1916,7 +1916,7 @@ impl ansi::Handler for Term {
#[inline]
fn reverse_index(&mut self) {
trace!("reverse_index");
trace!("Reversing index");
// if cursor is at the top
if self.cursor.point.line == self.scroll_region.start {
self.scroll_down(Line(1));
@ -1928,7 +1928,7 @@ impl ansi::Handler for Term {
/// set a terminal attribute
#[inline]
fn terminal_attribute(&mut self, attr: Attr) {
trace!("Set Attribute: {:?}", attr);
trace!("Setting attribute: {:?}", attr);
match attr {
Attr::Foreground(color) => self.cursor.template.fg = color,
Attr::Background(color) => self.cursor.template.bg = color,
@ -1959,7 +1959,7 @@ impl ansi::Handler for Term {
#[inline]
fn set_mode(&mut self, mode: ansi::Mode) {
trace!("set_mode: {:?}", mode);
trace!("Setting mode: {:?}", mode);
match mode {
ansi::Mode::SwapScreenAndSetRestoreCursor => {
self.mode.insert(mode::TermMode::ALT_SCREEN);
@ -1991,15 +1991,15 @@ impl ansi::Handler for Term {
ansi::Mode::Origin => self.mode.insert(mode::TermMode::ORIGIN),
ansi::Mode::DECCOLM => self.deccolm(),
ansi::Mode::Insert => self.mode.insert(mode::TermMode::INSERT), // heh
_ => {
trace!(".. ignoring set_mode");
ansi::Mode::BlinkingCursor => {
trace!("... unimplemented mode");
}
}
}
#[inline]
fn unset_mode(&mut self,mode: ansi::Mode) {
trace!("unset_mode: {:?}", mode);
trace!("Unsetting mode: {:?}", mode);
match mode {
ansi::Mode::SwapScreenAndSetRestoreCursor => {
self.mode.remove(mode::TermMode::ALT_SCREEN);
@ -2031,15 +2031,15 @@ impl ansi::Handler for Term {
ansi::Mode::Origin => self.mode.remove(mode::TermMode::ORIGIN),
ansi::Mode::DECCOLM => self.deccolm(),
ansi::Mode::Insert => self.mode.remove(mode::TermMode::INSERT),
_ => {
trace!(".. ignoring unset_mode");
ansi::Mode::BlinkingCursor => {
trace!("... unimplemented mode");
}
}
}
#[inline]
fn set_scrolling_region(&mut self, region: Range<Line>) {
trace!("set scroll region: {:?}", region);
trace!("Setting scrolling region: {:?}", region);
self.scroll_region.start = min(region.start, self.grid.num_lines());
self.scroll_region.end = min(region.end, self.grid.num_lines());
self.goto(Line(0), Column(0));
@ -2047,31 +2047,31 @@ impl ansi::Handler for Term {
#[inline]
fn set_keypad_application_mode(&mut self) {
trace!("set mode::TermMode::APP_KEYPAD");
trace!("Setting keypad application mode");
self.mode.insert(mode::TermMode::APP_KEYPAD);
}
#[inline]
fn unset_keypad_application_mode(&mut self) {
trace!("unset mode::TermMode::APP_KEYPAD");
trace!("Unsetting keypad application mode");
self.mode.remove(mode::TermMode::APP_KEYPAD);
}
#[inline]
fn configure_charset(&mut self, index: CharsetIndex, charset: StandardCharset) {
trace!("designate {:?} character set as {:?}", index, charset);
trace!("Configuring charset {:?} as {:?}", index, charset);
self.cursor.charsets[index] = charset;
}
#[inline]
fn set_active_charset(&mut self, index: CharsetIndex) {
trace!("Activate {:?} character set", index);
trace!("Setting active charset {:?}", index);
self.active_charset = index;
}
#[inline]
fn set_cursor_style(&mut self, style: Option<CursorStyle>) {
trace!("set_cursor_style {:?}", style);
trace!("Setting cursor style {:?}", style);
self.cursor_style = style;
}
}

View File

@ -316,7 +316,7 @@ pub fn new<T: ToWinsize>(
pty
},
Err(err) => {
die!("Command::spawn() failed: {}", err);
die!("Failed to spawn command: {}", err);
}
}
}

View File

@ -85,10 +85,10 @@ pub fn new<'a>(
window_id: Option<usize>,
) -> Pty<'a> {
if let Some(pty) = conpty::new(config, options, size, window_id) {
info!("Using Conpty agent.");
info!("Using Conpty agent");
pty
} else {
info!("Using Winpty agent.");
info!("Using Winpty agent");
winpty::new(config, options, size, window_id)
}
}

View File

@ -140,8 +140,8 @@ impl<'a> Drop for Config<'a> {
pub struct Winpty<'a>(&'a mut winpty_t);
impl<'a, 'b> Winpty<'a> {
/// Starts the agent. This process will connect to the agent
/// over a control pipe, and the agent will open data pipes
/// Starts the agent. This process will connect to the agent
/// over a control pipe, and the agent will open data pipes
/// (e.g. CONIN and CONOUT).
pub fn open(cfg: &Config) -> Result<Self, Err<'b>> {
let mut err = null_mut() as *mut winpty_error_t;
@ -199,7 +199,7 @@ impl<'a, 'b> Winpty<'a> {
}
/// Change the size of the Windows console window.
///
///
/// cols & rows MUST be greater than 0
pub fn set_size(&mut self, cols: u16, rows: u16) -> Result<(), Err> {
assert!(cols > 0 && rows > 0);
@ -339,7 +339,7 @@ impl<'a> Drop for SpawnConfig<'a> {
}
}
}
#[cfg(test)]
mod tests {
extern crate named_pipe;