summaryrefslogtreecommitdiff
path: root/src/logging.rs
diff options
context:
space:
mode:
authorNathan Lilienthal <nathan@nixpulvis.com>2019-01-06 19:06:57 -0500
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-01-07 00:06:57 +0000
commit04707cbba630e3e4ad6b4200bef8ae7888c49e3b (patch)
treebd04f4964d4c4ad67cd565b38172b488172acfcc /src/logging.rs
parentdfc30eeef5eb6df9f658e62875e5cde93173e37b (diff)
downloadalacritty-04707cbba630e3e4ad6b4200bef8ae7888c49e3b.tar.gz
alacritty-04707cbba630e3e4ad6b4200bef8ae7888c49e3b.zip
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".
Diffstat (limited to 'src/logging.rs')
-rw-r--r--src/logging.rs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/logging.rs b/src/logging.rs
index 1767724c..893a39a2 100644
--- a/src/logging.rs
+++ b/src/logging.rs
@@ -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());