Commit

Author:

Hash:

Timestamp:

+26 -29 +/-8 browse

Kevin Schoon [me@kevinschoon.com]

8c956f6e41f6e03a15b6a8e99143c644026f8261

Sun, 27 Jul 2025 09:41:55 +0000 (3 months ago)

drop log crate
1diff --git a/Cargo.lock b/Cargo.lock
2index 9dbddd7..b13dd7b 100644
3--- a/Cargo.lock
4+++ b/Cargo.lock
5 @@ -337,7 +337,6 @@ dependencies = [
6 "include_dir",
7 "lazy_static",
8 "libloading",
9- "log",
10 "mime",
11 "mime_guess",
12 "nix",
13 diff --git a/ayllu/Cargo.toml b/ayllu/Cargo.toml
14index 31b14ff..20032bf 100644
15--- a/ayllu/Cargo.toml
16+++ b/ayllu/Cargo.toml
17 @@ -41,7 +41,6 @@ serde_json = "1.0.140"
18 tree-sitter = "0.25.6"
19 tabwriter = "1.4.1"
20 libloading = "0.8.8"
21- log = "0.4.27"
22 rss = "2.0.12"
23 globwalk = "0.9.1"
24 anyhow = "1.0.98"
25 diff --git a/ayllu/src/highlight.rs b/ayllu/src/highlight.rs
26index a603268..d81d51e 100644
27--- a/ayllu/src/highlight.rs
28+++ b/ayllu/src/highlight.rs
29 @@ -8,7 +8,6 @@ use std::sync::RwLock;
30
31 use comrak::adapters::SyntaxHighlighterAdapter;
32 use lazy_static::lazy_static;
33- use log::debug;
34 use tree_sitter::Language;
35 use tree_sitter_highlight::{HighlightConfiguration, Highlighter as TSHighlighter, HtmlRenderer};
36
37 @@ -50,7 +49,7 @@ unsafe fn load_language(path: &str, hint: &Hint) -> Language {
38 // for tree-sitter function names.
39 let method_name = format!("tree_sitter_{}", hint.0.to_lowercase().replace('-', "_"));
40 // NOTE: maybe, probably? some security auditing that needs to happen here?
41- debug!("attempting to load method: {method_name}");
42+ tracing::debug!("attempting to load method: {method_name}");
43 let func: libloading::Symbol<unsafe extern "C" fn() -> Language> =
44 lib.get(method_name.as_bytes()).unwrap();
45 let language = func();
46 @@ -123,12 +122,12 @@ impl Loader {
47 .write()
48 .unwrap()
49 .insert(hint.clone(), highlight_scm);
50- debug!("loaded [{:?}] {}", hint, query.path().display());
51+ tracing::debug!("loaded [{:?}] {}", hint, query.path().display());
52 }
53 "locals.scm" => {
54 let locals_scm = fs::read_to_string(query.path())?;
55 LOCALS.write().unwrap().insert(hint.clone(), locals_scm);
56- debug!("loaded [{:?}] {}", hint, query.path().display());
57+ tracing::debug!("loaded [{:?}] {}", hint, query.path().display());
58 }
59 "injections.scm" => {
60 let injections_scm = fs::read_to_string(query.path())?;
61 @@ -136,10 +135,10 @@ impl Loader {
62 .write()
63 .unwrap()
64 .insert(hint.clone(), injections_scm);
65- debug!("loaded [{:?}] {}", hint, query.path().display());
66+ tracing::debug!("loaded [{:?}] {}", hint, query.path().display());
67 }
68 name => {
69- debug!("ignoring query file: {name}")
70+ tracing::debug!("ignoring query file: {name}")
71 }
72 }
73 }
74 @@ -149,7 +148,7 @@ impl Loader {
75 .write()
76 .unwrap()
77 .insert(hint.clone(), overrides.clone());
78- debug!("user supplied their own highlights.scm for {hint:?}");
79+ tracing::debug!("user supplied their own highlights.scm for {hint:?}");
80 }
81 Ok(())
82 }
83 @@ -180,7 +179,7 @@ impl Loader {
84 let hint = Hint(language_name);
85 let language = unsafe { load_language(fp.path().to_str().unwrap(), &hint) };
86 LANGUAGES.write().unwrap().insert(hint.clone(), language);
87- debug!(
88+ tracing::debug!(
89 "loaded tree-sitter shared module: [{:?}] {}",
90 hint,
91 fp.path().display()
92 @@ -297,7 +296,7 @@ impl Highlighter {
93 None => LANGUAGE_TABLE.guess(code, alias, filepath),
94 };
95
96- debug!("language hint: {hint:?}");
97+ tracing::debug!("language hint: {hint:?}");
98
99 match hint {
100 Some(hint) => match (
101 @@ -305,7 +304,7 @@ impl Highlighter {
102 HIGHLIGHTS.read().unwrap().get(&hint),
103 ) {
104 (Some(language), Some(syntax)) => {
105- debug!("painting syntax for language: {hint:?}");
106+ tracing::debug!("painting syntax for language: {hint:?}");
107 let mut highlighter = TSHighlighter::new();
108 let injections = INJECTIONS
109 .read()
110 @@ -350,7 +349,7 @@ impl Highlighter {
111 )
112 }
113 _ => {
114- debug!("cannot paint syntax for language: {hint:?}");
115+ tracing::debug!("cannot paint syntax for language: {hint:?}");
116 let escaped = askama::filters::escape(code, askama::filters::Html).unwrap();
117 (
118 None,
119 @@ -359,7 +358,7 @@ impl Highlighter {
120 }
121 },
122 None => {
123- debug!("cannot determine language");
124+ tracing::debug!("cannot determine language");
125 let escaped = askama::filters::escape(code, askama::filters::Html).unwrap();
126 (
127 None,
128 diff --git a/ayllu/src/web2/middleware/error.rs b/ayllu/src/web2/middleware/error.rs
129index e917064..39f3c0f 100644
130--- a/ayllu/src/web2/middleware/error.rs
131+++ b/ayllu/src/web2/middleware/error.rs
132 @@ -44,7 +44,7 @@ pub async fn middleware(
133 Error::ComponentNotEnabled(_) => StatusCode::INTERNAL_SERVER_ERROR,
134 };
135 if status_code == StatusCode::NOT_FOUND {
136- log::warn!("Not Found: {error}");
137+ tracing::warn!("Not Found: {error}");
138 return Html::from(
139 NotFoundPage {
140 base: Base {
141 @@ -59,7 +59,7 @@ pub async fn middleware(
142 )
143 .into_response();
144 } else {
145- log::error!("Error: {error}");
146+ tracing::error!("Error: {error}");
147 return Html::from(
148 ErrorPage {
149 base: Base {
150 diff --git a/ayllu/src/web2/middleware/sites.rs b/ayllu/src/web2/middleware/sites.rs
151index 8c38452..ced5692 100644
152--- a/ayllu/src/web2/middleware/sites.rs
153+++ b/ayllu/src/web2/middleware/sites.rs
154 @@ -46,7 +46,7 @@ pub fn sites(cfg: &Config) -> Result<Sites, Error> {
155 Some((key, value)) => {
156 let repo_path = path.to_str().unwrap().to_string();
157 sites.push((repo_path.to_string(), (key.to_string(), value.to_string())));
158- log::info!("serving static site {domain} -> {repo_path}");
159+ tracing::info!("serving static site {domain} -> {repo_path}");
160 }
161 None => panic!("bad key=value header"),
162 };
163 @@ -72,10 +72,10 @@ pub async fn middleware(
164 .map(|header| header.to_str().unwrap_or(""));
165
166 for (other_repo_path, (key, value)) in sites {
167- log::debug!("checking site {other_repo_path} {key}={value}");
168+ tracing::debug!("checking site {other_repo_path} {key}={value}");
169 if let Some(header_value) = headers.get(key.as_str()) {
170 if header_value.to_str().unwrap() == value {
171- log::debug!("sites header match: {key}={value}");
172+ tracing::debug!("sites header match: {key}={value}");
173 repo_path = Some(other_repo_path.to_string());
174 break;
175 // return self.serve(req, repo_path).await;
176 @@ -117,11 +117,11 @@ pub async fn middleware(
177 paths.push(blob_path.clone().with_extension("html"));
178 paths.push(blob_path.clone().with_extension("htm"));
179 };
180- log::debug!("trying paths: {paths:?}");
181+ tracing::debug!("trying paths: {paths:?}");
182 for path in paths {
183- log::debug!("trying path {path:?}");
184+ tracing::debug!("trying path {path:?}");
185 if let Some(blob) = repository.blob(path.as_path(), sites_config.branch.clone())? {
186- log::debug!("got blob from path {path:?}");
187+ tracing::debug!("got blob from path {path:?}");
188 let mime_type = from_path(path.to_str().unwrap()).first_or_octet_stream();
189 let response = Response::builder()
190 .header(header::CONTENT_TYPE, mime_type.to_string())
191 diff --git a/ayllu/src/web2/routes/blob.rs b/ayllu/src/web2/routes/blob.rs
192index 72ba6ab..800b3b5 100644
193--- a/ayllu/src/web2/routes/blob.rs
194+++ b/ayllu/src/web2/routes/blob.rs
195 @@ -66,7 +66,7 @@ pub async fn serve(
196 base.title = preamble.file_name();
197 base.nav_elements = navigation::primary("blob", &preamble.collection_name, &preamble.repo_name);
198 let mime_type = mime_guess::from_path(preamble.file_path_string()).first_or_octet_stream();
199- log::debug!("rendering blob with mime type: {mime_type}");
200+ tracing::debug!("rendering blob with mime type: {mime_type}");
201 let mut content: Option<String> = None;
202 let mut is_image = false;
203 let mut is_video = false;
204 @@ -167,7 +167,7 @@ pub async fn serve_raw(
205 preamble.repo_name.as_str(),
206 blob.oid.as_str(),
207 );
208- log::debug!("redirecting blob to LFS server: {location}");
209+ tracing::debug!("redirecting blob to LFS server: {location}");
210 Ok(Redirect::permanent(&location).into_response())
211 } else {
212 let mime = if blob.is_binary {
213 @@ -177,7 +177,7 @@ pub async fn serve_raw(
214 } else {
215 mime_guess::mime::TEXT_PLAIN.to_string()
216 };
217- log::debug!(
218+ tracing::debug!(
219 "serving blob {} with mime {}",
220 preamble.file_path_string(),
221 mime
222 diff --git a/ayllu/src/web2/routes/git.rs b/ayllu/src/web2/routes/git.rs
223index 2ae5c3a..d76eb1a 100644
224--- a/ayllu/src/web2/routes/git.rs
225+++ b/ayllu/src/web2/routes/git.rs
226 @@ -86,7 +86,7 @@ pub async fn handle(
227 return Err(Error::NotFound("repository not found".to_string()));
228 }
229
230- log::info!(
231+ tracing::info!(
232 "handling git clone operation on {}/{} [{}]",
233 preamble.collection_name,
234 preamble.repo_name,
235 @@ -121,7 +121,7 @@ pub async fn handle(
236 .stderr(Stdio::piped())
237 .kill_on_drop(true);
238
239- log::debug!("calling {cmd:?}");
240+ tracing::debug!("calling {cmd:?}");
241
242 if cfg.git.export_all {
243 cmd = cmd.env("GIT_HTTP_EXPORT_ALL", "true");
244 diff --git a/ayllu/src/web2/server.rs b/ayllu/src/web2/server.rs
245index 80b03f4..946e7ec 100644
246--- a/ayllu/src/web2/server.rs
247+++ b/ayllu/src/web2/server.rs
248 @@ -58,7 +58,7 @@ pub async fn serve(cfg: &Config) -> Result<(), Box<dyn Error>> {
249 ts_config.keywords.clone()
250 }
251 None => {
252- log::warn!("tree-sitter is not configured, syntax highlighting will be disabled");
253+ tracing::warn!("tree-sitter is not configured, syntax highlighting will be disabled");
254 Vec::new()
255 }
256 };
257 @@ -175,7 +175,7 @@ pub async fn serve(cfg: &Config) -> Result<(), Box<dyn Error>> {
258 .on_response(DefaultOnResponse::new().level(Level::INFO)),
259 ),
260 );
261- log::info!("listening @ {}", cfg.http.address);
262+ tracing::info!("listening @ {}", cfg.http.address);
263 let listener = TcpListener::bind(address).await?;
264 axum::serve(listener, ServiceExt::<Request>::into_make_service(app)).await?;
265 Ok(())