@@ -32,7 +32,7 @@ fn bind_mount(source: &Path, dest: &Path) {
3232 MsFlags :: MS_BIND | MsFlags :: MS_REC | MsFlags :: MS_PRIVATE ,
3333 NONE ,
3434 ) {
35- eprintln ! (
35+ log :: error !(
3636 "failed to bind mount {} to {}: {}" ,
3737 source. display( ) ,
3838 dest. display( ) ,
@@ -198,7 +198,7 @@ impl<'a> RunChroot<'a> {
198198 }
199199 }
200200
201- eprintln ! ( "BIND DIRECTORY {} -> {}" , entry. path( ) . display( ) , mountpoint. display( ) ) ;
201+ log :: info !( "BIND DIRECTORY {} -> {}" , entry. path( ) . display( ) , mountpoint. display( ) ) ;
202202
203203 bind_mount ( & entry. path ( ) , & mountpoint)
204204 } else {
@@ -246,7 +246,7 @@ impl<'a> RunChroot<'a> {
246246 let target = self . resolve_nix_path ( path. clone ( ) , true )
247247 . unwrap_or_else ( |err| panic ! ( "failed to resolve symlink {}: {}" , & path. display( ) , err) ) ;
248248
249- eprintln ! ( "MIRROR SYMLINK {} -> {}" , target. display( ) , link_path. display( ) ) ;
249+ log :: info !( "MIRROR SYMLINK {} -> {}" , target. display( ) , link_path. display( ) ) ;
250250
251251 symlink ( & target, & link_path) . unwrap_or_else ( |err| {
252252 panic ! (
@@ -379,7 +379,7 @@ impl<'a> RunChroot<'a> {
379379
380380 for ( src, dest) in explicit_mounts {
381381 if let Ok ( src) = self . resolve_nix_path ( src. clone ( ) , true ) {
382- eprintln ! ( "{} -> {}" , src. display( ) , dest. display( ) ) ;
382+ log :: info !( "EXPLICIT {} -> {}" , src. display( ) , dest. display( ) ) ;
383383
384384 let adjusted_dest = dest
385385 . strip_prefix ( "/" ) // we have guarantees that `dest` is absolute
@@ -412,7 +412,7 @@ impl<'a> RunChroot<'a> {
412412
413413 for p in mount_exclude_list {
414414 let mount = self . rootdir . join ( p. strip_prefix ( "/" ) . unwrap ( ) ) ;
415- eprintln ! ( "UNBIND {}" , mount. display( ) ) ;
415+ log :: info !( "UNBIND {}" , mount. display( ) ) ;
416416 umount ( & mount) . unwrap ( ) ;
417417 }
418418
@@ -504,6 +504,12 @@ fn wait_for_child(rootdir: &Path, child_pid: unistd::Pid) -> ! {
504504}
505505
506506fn main ( ) {
507+ let mut builder = env_logger:: Builder :: new ( ) ;
508+ builder
509+ . filter_level ( log:: LevelFilter :: Warn )
510+ . parse_default_env ( )
511+ . init ( ) ;
512+
507513 let args: Vec < String > = env:: args ( ) . collect ( ) ;
508514 if args. len ( ) < 3 {
509515 eprintln ! ( "Usage: {} <nixpath> <command>\n " , args[ 0 ] ) ;
0 commit comments