@@ -4,12 +4,44 @@ use crate::node_types::{self, EntryKind, Field, NodeTypeMap, Storage, TypeName};
44use crate :: trap;
55use std:: collections:: BTreeMap as Map ;
66use std:: collections:: BTreeSet as Set ;
7+ use std:: env;
78use std:: path:: Path ;
89
910use tree_sitter:: { Language , Node , Parser , Range , Tree } ;
1011
1112pub mod simple;
1213
14+ /// Sets the tracing level based on the environment variables
15+ /// `RUST_LOG` and `CODEQL_VERBOSITY` (prioritized in that order),
16+ /// falling back to `warn` if neither is set.
17+ pub fn set_tracing_level ( language : & str ) -> ( ) {
18+ tracing_subscriber:: fmt ( )
19+ . with_target ( false )
20+ . without_time ( )
21+ . with_level ( true )
22+ . with_env_filter (
23+ tracing_subscriber:: EnvFilter :: try_from_default_env ( ) . unwrap_or_else (
24+ |_| -> tracing_subscriber:: EnvFilter {
25+ let verbosity = env:: var ( "CODEQL_VERBOSITY" )
26+ . map ( |v| match v. to_lowercase ( ) . as_str ( ) {
27+ "off" | "errors" => "error" ,
28+ "warnings" => "warn" ,
29+ "info" | "progress" => "info" ,
30+ "debug" | "progress+" => "debug" ,
31+ "trace" | "progress++" | "progress+++" => "trace" ,
32+ _ => "warn" ,
33+ } )
34+ . unwrap_or_else ( |_| "warn" ) ;
35+ tracing_subscriber:: EnvFilter :: new ( format ! (
36+ "{}_extractor={}" ,
37+ language, verbosity
38+ ) )
39+ } ,
40+ ) ,
41+ )
42+ . init ( ) ;
43+ }
44+
1345pub fn populate_file ( writer : & mut trap:: Writer , absolute_path : & Path ) -> trap:: Label {
1446 let ( file_label, fresh) = writer. global_id ( & trap:: full_id_for_file (
1547 & file_paths:: normalize_path ( absolute_path) ,
0 commit comments