log syntax highlighting init errors (#895)

pull/897/head
Kirawi 3 years ago committed by GitHub
parent 0f886af4b9
commit 0cb5e0b2ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
Cargo.lock generated

@ -363,6 +363,7 @@ dependencies = [
"arc-swap", "arc-swap",
"etcetera", "etcetera",
"helix-syntax", "helix-syntax",
"log",
"once_cell", "once_cell",
"quickcheck", "quickcheck",
"regex", "regex",

@ -27,6 +27,7 @@ once_cell = "1.8"
arc-swap = "1" arc-swap = "1"
regex = "1" regex = "1"
log = "0.4"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
toml = "0.5" toml = "0.5"

@ -186,7 +186,9 @@ impl LanguageConfiguration {
if highlights_query.is_empty() { if highlights_query.is_empty() {
None None
} else { } else {
let language = get_language(&crate::RUNTIME_DIR, &self.language_id).ok()?; let language = get_language(&crate::RUNTIME_DIR, &self.language_id)
.map_err(|e| log::info!("{}", e))
.ok()?;
let config = HighlightConfiguration::new( let config = HighlightConfiguration::new(
language, language,
&highlights_query, &highlights_query,

@ -16,6 +16,11 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
}; };
// Separate file config so we can include year, month and day in file logs // Separate file config so we can include year, month and day in file logs
let file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(logpath)?;
let file_config = fern::Dispatch::new() let file_config = fern::Dispatch::new()
.format(|out, message, record| { .format(|out, message, record| {
out.finish(format_args!( out.finish(format_args!(
@ -26,7 +31,7 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
message message
)) ))
}) })
.chain(fern::log_file(logpath)?); .chain(file);
base_config.chain(file_config).apply()?; base_config.chain(file_config).apply()?;

@ -116,7 +116,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
} }
} else { } else {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
return Box::new(provider::WindowsProvider::new()); return Box::new(provider::WindowsProvider::default());
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
return Box::new(provider::NopProvider::new()); return Box::new(provider::NopProvider::new());
@ -145,15 +145,15 @@ mod provider {
use anyhow::{bail, Context as _, Result}; use anyhow::{bail, Context as _, Result};
use std::borrow::Cow; use std::borrow::Cow;
#[cfg(not(target_os = "windows"))]
#[derive(Debug)] #[derive(Debug)]
pub struct NopProvider { pub struct NopProvider {
buf: String, buf: String,
primary_buf: String, primary_buf: String,
} }
#[cfg(not(target_os = "windows"))]
impl NopProvider { impl NopProvider {
#[allow(dead_code)]
// Only dead_code on Windows.
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
buf: String::new(), buf: String::new(),
@ -162,6 +162,7 @@ mod provider {
} }
} }
#[cfg(not(target_os = "windows"))]
impl ClipboardProvider for NopProvider { impl ClipboardProvider for NopProvider {
fn name(&self) -> Cow<str> { fn name(&self) -> Cow<str> {
Cow::Borrowed("none") Cow::Borrowed("none")
@ -186,19 +187,8 @@ mod provider {
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
#[derive(Debug)] #[derive(Default, Debug)]
pub struct WindowsProvider { pub struct WindowsProvider;
selection_buf: String,
}
#[cfg(target_os = "windows")]
impl WindowsProvider {
pub fn new() -> Self {
Self {
selection_buf: String::new(),
}
}
}
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
impl ClipboardProvider for WindowsProvider { impl ClipboardProvider for WindowsProvider {

@ -294,7 +294,11 @@ impl Editor {
self.language_servers self.language_servers
.get(language) .get(language)
.map_err(|e| { .map_err(|e| {
log::error!("Failed to get LSP, {}, for `{}`", e, language.scope()) log::error!(
"Failed to initialize the LSP for `{}` {{ {} }}",
language.scope(),
e
)
}) })
.ok() .ok()
}); });

Loading…
Cancel
Save