mirror of
https://github.com/github/codeql.git
synced 2026-04-21 23:14:03 +02:00
Rust: drop tracing:: qualifiers
This commit is contained in:
@@ -15,7 +15,7 @@ use std::{
|
||||
collections::HashMap,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use tracing::{info, warn};
|
||||
use tracing::{error, info, warn};
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<'a> Extractor<'a> {
|
||||
}
|
||||
translator.emit_source_file(ast);
|
||||
translator.trap.commit().unwrap_or_else(|err| {
|
||||
tracing::error!(
|
||||
error!(
|
||||
"Failed to write trap file for: {}: {}",
|
||||
display_path,
|
||||
err.to_string()
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::rc::Rc;
|
||||
use tracing::{debug, error, info, warn};
|
||||
use tracing::{debug, error, info, trace, warn};
|
||||
use triomphe::Arc;
|
||||
|
||||
pub enum RustAnalyzer<'a> {
|
||||
@@ -51,7 +51,7 @@ impl<'a> RustAnalyzer<'a> {
|
||||
project: &ProjectManifest,
|
||||
config: &CargoConfig,
|
||||
) -> Option<(RootDatabase, Vfs)> {
|
||||
let progress = |t| (tracing::trace!("progress: {}", t));
|
||||
let progress = |t| (trace!("progress: {}", t));
|
||||
let load_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
|
||||
@@ -62,7 +62,7 @@ impl<'a> RustAnalyzer<'a> {
|
||||
match load_workspace_at(manifest.as_ref(), config, &load_config, &progress) {
|
||||
Ok((db, vfs, _macro_server)) => Some((db, vfs)),
|
||||
Err(err) => {
|
||||
tracing::error!("failed to load workspace for {}: {}", manifest, err);
|
||||
error!("failed to load workspace for {}: {}", manifest, err);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,18 @@ macro_rules! emit_detached {
|
||||
($($_:tt)*) => {};
|
||||
}
|
||||
|
||||
// see https://github.com/tokio-rs/tracing/issues/2730
|
||||
macro_rules! dispatch_to_tracing {
|
||||
($lvl:ident, $($arg:tt)+) => {
|
||||
match $lvl {
|
||||
DiagnosticSeverity::Debug => ::tracing::debug!($($arg)+),
|
||||
DiagnosticSeverity::Info => ::tracing::info!($($arg)+),
|
||||
DiagnosticSeverity::Warning => ::tracing::warn!($($arg)+),
|
||||
DiagnosticSeverity::Error => ::tracing::error!($($arg)+),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub struct Translator<'a> {
|
||||
pub trap: TrapFile,
|
||||
path: &'a str,
|
||||
@@ -169,36 +181,14 @@ impl<'a> Translator<'a> {
|
||||
location: (LineCol, LineCol),
|
||||
) {
|
||||
let (start, end) = location;
|
||||
match severity {
|
||||
DiagnosticSeverity::Debug => tracing::debug!(
|
||||
"{}:{}:{}: {}",
|
||||
self.path,
|
||||
start.line + 1,
|
||||
start.col + 1,
|
||||
&full_message
|
||||
),
|
||||
DiagnosticSeverity::Info => tracing::info!(
|
||||
"{}:{}:{}: {}",
|
||||
self.path,
|
||||
start.line + 1,
|
||||
start.col + 1,
|
||||
&full_message
|
||||
),
|
||||
DiagnosticSeverity::Warning => tracing::warn!(
|
||||
"{}:{}:{}: {}",
|
||||
self.path,
|
||||
start.line + 1,
|
||||
start.col + 1,
|
||||
&full_message
|
||||
),
|
||||
DiagnosticSeverity::Error => tracing::error!(
|
||||
"{}:{}:{}: {}",
|
||||
self.path,
|
||||
start.line + 1,
|
||||
start.col + 1,
|
||||
&full_message
|
||||
),
|
||||
};
|
||||
dispatch_to_tracing!(
|
||||
severity,
|
||||
"{}:{}:{}: {}",
|
||||
self.path,
|
||||
start.line + 1,
|
||||
start.col + 1,
|
||||
&full_message,
|
||||
);
|
||||
|
||||
if severity > DiagnosticSeverity::Debug {
|
||||
let location = self.trap.emit_location_label(self.label, start, end);
|
||||
|
||||
Reference in New Issue
Block a user