oracle / railcar

RailCar: Rust implementation of the Open Containers Initiative oci-runtime
Other
1.12k stars 101 forks source link

log output accordingly : either --log or stdout #33

Closed rkgade closed 6 years ago

rkgade commented 6 years ago

Was unable to get debug log to logfile. Hence, added a value 'logfile' to SimpleLogger log checks if the value of --log attribute is empty or not. If there is a value, it writes to the mentioned file, else it goes to stderr/stdout.

rkgade commented 6 years ago

With --log option

$ ls | grep funny.log $ sudo railcar/railcar -v --log ~/funny.log run funny -b ~/runc/fun_c / # touch hi touch: hi: Read-only file system / # exit $ ls -ltr | grep funny.log -rw-r--r-- 1 root root 5711 Jan 23 18:51 funny.log $ funny.log

Without --log option, but with -v option $ sudo railcar/railcar -v run funny -b ~/runc/fun_c DEBUG - ensuring railcar state dir /run/railcar DEBUG - creating cgroup dir /sys/fs/cgroup/cpu,cpuacct/funny DEBUG - writing 18495 to /sys/fs/cgroup/cpu,cpuacct/funny/cgroup.procs DEBUG - writing 18495 to /sys/fs/cgroup/cpu,cpuacct/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/memory/funny DEBUG - writing 18495 to /sys/fs/cgroup/memory/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/systemd/user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service/funny DEBUG - writing 18495 to /sys/fs/cgroup/systemd/user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/freezer/funny DEBUG - writing 18495 to /sys/fs/cgroup/freezer/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/net_cls,net_prio/funny DEBUG - writing 18495 to /sys/fs/cgroup/net_cls,net_prio/funny/cgroup.procs DEBUG - writing 18495 to /sys/fs/cgroup/net_cls,net_prio/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/pids/user.slice/user-1000.slice/user@1000.service/funny DEBUG - writing 18495 to /sys/fs/cgroup/pids/user.slice/user-1000.slice/user@1000.service/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/blkio/funny DEBUG - writing 18495 to /sys/fs/cgroup/blkio/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/devices/user.slice/funny DEBUG - writing a : rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.deny DEBUG - writing c 1:3 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 1:5 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 1:7 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 5:0 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 1:9 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 1:8 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c : m to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing b : m to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 5:1 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 136:* rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 5:2 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing c 10:200 rwm to /sys/fs/cgroup/devices/user.slice/funny/devices.allow DEBUG - writing 18495 to /sys/fs/cgroup/devices/user.slice/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/cpuset/funny DEBUG - read 0-3 from /sys/fs/cgroup/cpuset/cpuset.cpus DEBUG - writing 0-3 to /sys/fs/cgroup/cpuset/funny/cpuset.cpus DEBUG - read 0 from /sys/fs/cgroup/cpuset/cpuset.mems DEBUG - writing 0 to /sys/fs/cgroup/cpuset/funny/cpuset.mems DEBUG - writing 18495 to /sys/fs/cgroup/cpuset/funny/cgroup.procs DEBUG - creating cgroup dir /sys/fs/cgroup/perf_event/funny DEBUG - writing 18495 to /sys/fs/cgroup/perf_event/funny/cgroup.procs DEBUG - second parent exiting DEBUG - child exited with code 0 DEBUG - mounting proc to /proc as proc with data '' DEBUG - mounting tmpfs to /dev as tmpfs with data 'mode=755,size=65536k' DEBUG - mounting devpts to /dev/pts as devpts with data 'newinstance,ptmxmode=0666,mode=0620,gid=5' DEBUG - mounting shm to /dev/shm as tmpfs with data 'mode=1777,size=65536k' DEBUG - mounting mqueue to /dev/mqueue as mqueue with data '' DEBUG - mounting sysfs to /sys as sysfs with data '' DEBUG - mounting tmpfs to /sys/fs/cgroup as tmpfs with data '' DEBUG - mounting /sys/fs/cgroup/cpu,cpuacct/funny to /sys/fs/cgroup/cpu,cpuacct as bind with data '' DEBUG - mounting /sys/fs/cgroup/memory/funny to /sys/fs/cgroup/memory as bind with data '' DEBUG - mounting /sys/fs/cgroup/systemd/user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service/funny to /sys/fs/cgroup/systemd as bind with data '' DEBUG - mounting /sys/fs/cgroup/freezer/funny to /sys/fs/cgroup/freezer as bind with data '' DEBUG - mounting /sys/fs/cgroup/net_cls,net_prio/funny to /sys/fs/cgroup/net_cls,net_prio as bind with data '' DEBUG - mounting /sys/fs/cgroup/pids/user.slice/user-1000.slice/user@1000.service/funny to /sys/fs/cgroup/pids as bind with data '' DEBUG - mounting /sys/fs/cgroup/blkio/funny to /sys/fs/cgroup/blkio as bind with data '' DEBUG - mounting /sys/fs/cgroup/devices/user.slice/funny to /sys/fs/cgroup/devices as bind with data '' DEBUG - mounting /sys/fs/cgroup/cpuset/funny to /sys/fs/cgroup/cpuset as bind with data '' DEBUG - mounting /sys/fs/cgroup/perf_event/funny to /sys/fs/cgroup/perf_event as bind with data '' DEBUG - mknoding /dev/null DEBUG - mknoding /dev/zero DEBUG - mknoding /dev/full DEBUG - mknoding /dev/tty DEBUG - mknoding /dev/urandom DEBUG - mknoding /dev/random DEBUG - writing zero to pipe to trigger prestart DEBUG - actual pid of child is 18497 DEBUG - running prestart hooks DEBUG - ignoring mask of /proc/latency_stats because it doesn't exist DEBUG - ignoring mask of /sys/firmware because it doesn't exist DEBUG - ignoring mask of /proc/scsi because it doesn't exist DEBUG - setting ids DEBUG - dropping bounding capabilities to [CAP_AUDIT_WRITE, CAP_KILL, CAP_NET_BIND_SERVICE] DEBUG - writing zero to pipe to trigger poststart DEBUG - running poststart hooks DEBUG - adding "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" to env DEBUG - adding "TERM=xterm" to env / # touch hi touch: hi: Read-only file system / # exit DEBUG - got a sigchld DEBUG - all children terminated, exiting with 1 DEBUG - removing cgroup dir /sys/fs/cgroup/cpu,cpuacct/funny DEBUG - removing cgroup dir /sys/fs/cgroup/memory/funny DEBUG - removing cgroup dir /sys/fs/cgroup/systemd/user.slice/user-1000.slice/user@1000.service/gnome-terminal-server.service/funny DEBUG - removing cgroup dir /sys/fs/cgroup/freezer/funny DEBUG - removing cgroup dir /sys/fs/cgroup/net_cls,net_prio/funny DEBUG - removing cgroup dir /sys/fs/cgroup/pids/user.slice/user-1000.slice/user@1000.service/funny DEBUG - removing cgroup dir /sys/fs/cgroup/blkio/funny DEBUG - removing cgroup dir /sys/fs/cgroup/devices/user.slice/funny DEBUG - removing cgroup dir /sys/fs/cgroup/cpuset/funny DEBUG - removing cgroup dir /sys/fs/cgroup/perf_event/funny DEBUG - child exited with code 1 $

vishvananda commented 6 years ago

thanks for this. I have a concern. The --log parameter is exposed because docker expects to be able to set it, but it also expects logs to be in json format. I think this will break the docker integration, unfortunately. Also it looks like you used a different version of the fixes branch because it is removing some of the recent changes.

rkgade commented 6 years ago

Closing the PR in favour of new changes.