@@ -2,6 +2,7 @@ use std::collections;
2
2
use std:: fs;
3
3
use std:: io:: Write ;
4
4
use std:: path;
5
+ use std:: sync:: LazyLock ;
5
6
6
7
use anyhow:: Context as _;
7
8
use cobalt:: cobalt_model;
@@ -21,7 +22,7 @@ impl InitArgs {
21
22
pub ( crate ) fn run ( & self ) -> Result < ( ) > {
22
23
create_new_project ( & self . directory )
23
24
. with_context ( || anyhow:: format_err!( "Could not create a new cobalt project" ) ) ?;
24
- info ! ( "Created new project at {}" , self . directory. display( ) ) ;
25
+ log :: info!( "Created new project at {}" , self . directory. display( ) ) ;
25
26
26
27
Ok ( ( ) )
27
28
}
@@ -187,13 +188,12 @@ layout: default.liquid
187
188
{% endfor %}
188
189
" ;
189
190
190
- lazy_static ! {
191
- static ref DEFAULT : collections:: HashMap <& ' static str , & ' static str > =
192
- [ ( "pages" , INDEX_MD ) , ( "posts" , POST_MD ) ]
193
- . iter( )
194
- . cloned( )
195
- . collect( ) ;
196
- }
191
+ static DEFAULT : LazyLock < collections:: HashMap < & ' static str , & ' static str > > = LazyLock :: new ( || {
192
+ [ ( "pages" , INDEX_MD ) , ( "posts" , POST_MD ) ]
193
+ . iter ( )
194
+ . cloned ( )
195
+ . collect ( )
196
+ } ) ;
197
197
198
198
pub ( crate ) fn create_new_project < P : AsRef < path:: Path > > ( dest : P ) -> Result < ( ) > {
199
199
create_new_project_for_path ( dest. as_ref ( ) )
@@ -276,7 +276,7 @@ pub(crate) fn create_new_document(
276
276
cobalt_model:: files:: read_file ( & source_path)
277
277
. with_context ( || anyhow:: format_err!( "Failed to read default: {:?}" , source_path) ) ?
278
278
} else {
279
- debug ! (
279
+ log :: debug!(
280
280
"No custom default provided ({:?}), falling back to built-in" ,
281
281
source_path
282
282
) ;
@@ -323,7 +323,7 @@ pub(crate) fn create_new_document(
323
323
fs:: create_dir_all ( parent) ?;
324
324
}
325
325
create_file ( & file. abs_path , & doc) ?;
326
- info ! ( "Created new {} {}" , collection_slug, file. rel_path) ;
326
+ log :: info!( "Created new {} {}" , collection_slug, file. rel_path) ;
327
327
328
328
Ok ( ( ) )
329
329
}
@@ -333,7 +333,7 @@ fn create_file<P: AsRef<path::Path>>(path: P, content: &str) -> Result<()> {
333
333
}
334
334
335
335
fn create_file_for_path ( path : & path:: Path , content : & str ) -> Result < ( ) > {
336
- trace ! ( "Creating file {:?}" , path) ;
336
+ log :: trace!( "Creating file {:?}" , path) ;
337
337
338
338
let mut file = fs:: OpenOptions :: new ( )
339
339
. write ( true )
@@ -405,7 +405,7 @@ pub(crate) fn rename_document(
405
405
cobalt_model:: files:: write_document_file ( doc, & target. abs_path ) ?;
406
406
407
407
if !full_front. is_draft {
408
- warn ! ( "Renaming a published page might invalidate links" ) ;
408
+ log :: warn!( "Renaming a published page might invalidate links" ) ;
409
409
}
410
410
fs:: remove_file ( source) ?;
411
411
@@ -437,7 +437,10 @@ fn prepend_date_to_filename(
437
437
. first( )
438
438
. expect( "at least one element is enforced by config validator" ) )
439
439
) ;
440
- trace ! ( "`publish_date_in_filename` setting is activated, prefix filename with date, new filename: {}" , file_name) ;
440
+ log:: trace!(
441
+ "`publish_date_in_filename` setting is activated, prefix filename with date, new filename: {}" ,
442
+ file_name
443
+ ) ;
441
444
fs:: rename ( file, file. with_file_name ( file_name) ) ?;
442
445
Ok ( ( ) )
443
446
}
0 commit comments