@@ -32,7 +32,7 @@ fn bind_mount(source: &Path, dest: &Path) {
32
32
MsFlags :: MS_BIND | MsFlags :: MS_REC | MsFlags :: MS_PRIVATE ,
33
33
NONE ,
34
34
) {
35
- eprintln ! (
35
+ log :: error !(
36
36
"failed to bind mount {} to {}: {}" ,
37
37
source. display( ) ,
38
38
dest. display( ) ,
@@ -198,7 +198,7 @@ impl<'a> RunChroot<'a> {
198
198
}
199
199
}
200
200
201
- eprintln ! ( "BIND DIRECTORY {} -> {}" , entry. path( ) . display( ) , mountpoint. display( ) ) ;
201
+ log :: info !( "BIND DIRECTORY {} -> {}" , entry. path( ) . display( ) , mountpoint. display( ) ) ;
202
202
203
203
bind_mount ( & entry. path ( ) , & mountpoint)
204
204
} else {
@@ -246,7 +246,7 @@ impl<'a> RunChroot<'a> {
246
246
let target = self . resolve_nix_path ( path. clone ( ) , true )
247
247
. unwrap_or_else ( |err| panic ! ( "failed to resolve symlink {}: {}" , & path. display( ) , err) ) ;
248
248
249
- eprintln ! ( "MIRROR SYMLINK {} -> {}" , target. display( ) , link_path. display( ) ) ;
249
+ log :: info !( "MIRROR SYMLINK {} -> {}" , target. display( ) , link_path. display( ) ) ;
250
250
251
251
symlink ( & target, & link_path) . unwrap_or_else ( |err| {
252
252
panic ! (
@@ -379,7 +379,7 @@ impl<'a> RunChroot<'a> {
379
379
380
380
for ( src, dest) in explicit_mounts {
381
381
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( ) ) ;
383
383
384
384
let adjusted_dest = dest
385
385
. strip_prefix ( "/" ) // we have guarantees that `dest` is absolute
@@ -412,7 +412,7 @@ impl<'a> RunChroot<'a> {
412
412
413
413
for p in mount_exclude_list {
414
414
let mount = self . rootdir . join ( p. strip_prefix ( "/" ) . unwrap ( ) ) ;
415
- eprintln ! ( "UNBIND {}" , mount. display( ) ) ;
415
+ log :: info !( "UNBIND {}" , mount. display( ) ) ;
416
416
umount ( & mount) . unwrap ( ) ;
417
417
}
418
418
@@ -504,6 +504,12 @@ fn wait_for_child(rootdir: &Path, child_pid: unistd::Pid) -> ! {
504
504
}
505
505
506
506
fn main ( ) {
507
+ let mut builder = env_logger:: Builder :: new ( ) ;
508
+ builder
509
+ . filter_level ( log:: LevelFilter :: Warn )
510
+ . parse_default_env ( )
511
+ . init ( ) ;
512
+
507
513
let args: Vec < String > = env:: args ( ) . collect ( ) ;
508
514
if args. len ( ) < 3 {
509
515
eprintln ! ( "Usage: {} <nixpath> <command>\n " , args[ 0 ] ) ;
0 commit comments