#!/bin/bash # Util to pretty-print logfile of NetworkManager # # Unless setting NM_LOG_NO_COLOR it will colorize the output. # Suppress coloring with: # $ NM_LOG_NO_COLOR=1 NM-log ... # # If called without arguments, it either reads from stdin (if not # connected to a terminal) or it shows the journal content. # # If called with first argument "j", it always shows the journal content. # # You can pass multiple filenames. show-journal() { local since="$(systemctl show NetworkManager | sed -n 's/^ExecMainStartTimestamp=\(.*\) [A-Z0-9]\+$/\1/p')" if [[ "$since" == "" ]]; then echo "error detecting NM. Is it running?" systemctl status NetworkManager else exec journalctl -o short-precise --since "$since" -b 0 -u NetworkManager "$@" fi } colorize() { if [[ "$NM_LOG_NO_COLOR" == "" ]]; then GREP_COLOR='01;33' grep --color=always '^\|^\(.* \)\?<\(warn>\|info> \|error>\) \(.*\.*$\)\?' | \ GREP_COLOR='01;37' grep --color=always '^\|\