Using the Systemd-journal gem for the 1st time

Installation

gem install systemd-journal

Example

require 'systemd/journal'

Print all messages as they occur:

j = Systemd::Journal.new
j.seek(:tail)

# watch() does not return
j.watch do |entry|
  puts entry.message
end

Note: The above code was executed as root, and if you attempt to run it as non-root you won't observe any output.

Output

Most of the output below was generated as a result of the following:

pam_unix(sudo:session): session opened for user root by (uid=0)

<info> Activation (wlan0) starting connection 'Detroit'
<info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
<info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
<info> (wlan0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
<info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
<info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
<info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
<info> (wlan0): device state change: prepare -> config (reason 'none') [40 50 0]
<info> Activation (wlan0/wireless): connection 'Detroit' requires no security.  No secrets needed.
<info> Config: added 'ssid' value 'Detroit'
<info> Config: added 'scan_ssid' value '1'
<info> Config: added 'key_mgmt' value 'NONE'
<info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
<info> Config: set interface ap_scan to 1
<info> (wlan0): supplicant interface state: disconnected -> scanning
wlan0: authenticate with 02:8e:f2:d2:2b:47
wlan0: SME: Trying to authenticate with 02:8e:f2:d2:2b:47 (SSID='Detroit' freq=2437 MHz)
<info> (wlan0): supplicant interface state: scanning -> authenticating
wlan0: send auth to 02:8e:f2:d2:2b:47 (try 1/3)
wlan0: Trying to associate with 02:8e:f2:d2:2b:47 (SSID='Detroit' freq=2437 MHz)
wlan0: authenticated
wlan0: associate with 02:8e:f2:d2:2b:47 (try 1/3)
<info> (wlan0): supplicant interface state: authenticating -> associating
wlan0: Associated with 02:8e:f2:d2:2b:47
wlan0: CTRL-EVENT-CONNECTED - Connection to 02:8e:f2:d2:2b:47 completed [id=0 id_str=]
wlan0: RX AssocResp from 02:8e:f2:d2:2b:47 (capab=0x401 status=0 aid=1)
wlan0: associated
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
<info> (wlan0): supplicant interface state: associating -> completed
<info> Activation (wlan0/wireless) Stage 2 of 5 (Device Configure) successful.  Connected to wireless network 'Detroit'.
<info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) scheduled.
<info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) started...
<info> (wlan0): device state change: config -> ip-config (reason 'none') [50 70 0]
<info> Activation (wlan0) Beginning DHCPv4 transaction (timeout in 45 seconds)
<info> dhclient started with pid 6600
<info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) complete.
<info> (wlan0): DHCPv4 state changed nbi -> preinit
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.5.1
<info> (wlan0): DHCPv4 state changed preinit -> reboot
<info>   address 192.168.5.7
<info>   plen 24 (255.255.255.0)
<info>   gateway 192.168.5.1
<info>   server identifier 192.168.5.1
<info>   lease time 86400
<info>   nameserver '194.168.4.100'
<info>   nameserver '194.168.8.100'
<info> Activation (wlan0) Stage 5 of 5 (IPv4 Configure Commit) scheduled...
<info> Activation (wlan0) Stage 5 of 5 (IPv4 Commit) started...
<info> (wlan0): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
<info> Activation (wlan0) Stage 5 of 5 (IPv4 Commit) complete.
Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.5.7.
New relevant interface wlan0.IPv4 for mDNS.
Registering new address record for 192.168.5.7 on wlan0.IPv4.
<info> (wlan0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
<info> (wlan0): device state change: secondaries -> activated (reason 'none') [90 100 0]
bound to 192.168.5.7 -- renewal in 40435 seconds.
<info> Activation (wlan0) successful, device activated.
[system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
[system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dispatching action 'up' for wlan0
Received SIGHUP; restarting.
Server listening on 0.0.0.0 port 22.
Server listening on :: port 22.
Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::2ed0:5aff:fec1:528c.
New relevant interface wlan0.IPv6 for mDNS.
Registering new address record for fe80::2ed0:5aff:fec1:528c on wlan0.*.
ICMPv6 checksum failed [fe80::22e5:2aff:fed4:967f > ff02::1]
Listen normally on 9 wlan0 192.168.5.7 UDP 123
Listen normally on 10 wlan0 fe80::2ed0:5aff:fec1:528c UDP 123
peers refreshed
usb 1-3: USB disconnect, device number 4
(II) config/udev: removing device USB Optical Mouse
(II) evdev: USB Optical Mouse: Close
(II) UnloadModule: "evdev"
usb 1-3: new low-speed USB device number 5 using xhci_hcd
usb 1-3: New USB device found, idVendor=045e, idProduct=0797
usb 1-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
usb 1-3: Product: USB Optical Mouse
usb 1-3: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes
checking bus 1, device 5: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3"
bus: 1, device: 5 was not an MTP device
input: USB Optical Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:045E:0797.0005/input/input20
hid-generic 0003:045E:0797.0005: input,hidraw2: USB HID v1.11 Mouse [USB Optical Mouse] on usb-0000:00:14.0-3/input0
(II) config/udev: Adding input device USB Optical Mouse (/dev/input/mouse0)
(II) No input driver specified, ignoring this device.
(II) This device may have been added with another device file.
(II) config/udev: Adding input device USB Optical Mouse (/dev/input/event3)
(**) USB Optical Mouse: Applying InputClass "evdev pointer catchall"
(II) Using input driver 'evdev' for 'USB Optical Mouse'
(**) USB Optical Mouse: always reports core events
(**) evdev: USB Optical Mouse: Device: "/dev/input/event3"
(--) evdev: USB Optical Mouse: Vendor 0x45e Product 0x797
(--) evdev: USB Optical Mouse: Found 3 mouse buttons
(--) evdev: USB Optical Mouse: Found scroll wheel(s)
(--) evdev: USB Optical Mouse: Found relative axes
(--) evdev: USB Optical Mouse: Found x and y relative axes
(II) evdev: USB Optical Mouse: Configuring as mouse
(II) evdev: USB Optical Mouse: Adding scrollwheel support
(**) evdev: USB Optical Mouse: YAxisMapping: buttons 4 and 5
(**) evdev: USB Optical Mouse: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
(**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:045E:0797.0005/input/input20/event3"
(II) XINPUT: Adding extended input device "USB Optical Mouse" (type: MOUSE, id 12)
(II) evdev: USB Optical Mouse: initialized for relative axes.
(**) USB Optical Mouse: (accel) keeping acceleration scheme 1
(**) USB Optical Mouse: (accel) acceleration profile 0
(**) USB Optical Mouse: (accel) acceleration factor: 2.000
(**) USB Optical Mouse: (accel) acceleration threshold: 4
ICMPv6 checksum failed [fe80::22e5:2aff:fed4:967f > ff02::1]
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^CIRB::Abort: abort then interrupt!
    from /var/lib/gems/2.1.0/gems/systemd-journal-1.2.2/lib/systemd/journal/waitable.rb:22:in `call'
    from /var/lib/gems/2.1.0/gems/systemd-journal-1.2.2/lib/systemd/journal/waitable.rb:22:in `sd_journal_wait'
    from /var/lib/gems/2.1.0/gems/systemd-journal-1.2.2/lib/systemd/journal/waitable.rb:22:in `wait'
    from /var/lib/gems/2.1.0/gems/systemd-journal-1.2.2/lib/systemd/journal/waitable.rb:47:in `block in watch'
    from /var/lib/gems/2.1.0/gems/systemd-journal-1.2.2/lib/systemd/journal/waitable.rb:47:in `loop'
    from /var/lib/gems/2.1.0/gems/systemd-journal-1.2.2/lib/systemd/journal/waitable.rb:47:in `watch'
    from (irb):9
    from /usr/bin/irb:11:in `<main>'

Notes:

Resources