summary refs log tree commit diff
path: root/svlogtail
blob: 4e91149d29f18f3c480c0b18ce0200ea3ac5ea88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

usage () {
	cat <<-'EOF'
	svlogtail [LOG...] - show svlogd logs conveniently

	Without arguments, show current logs of all services, uniquely.
	With arguments, show all logs of mentioned services
	EOF
}

if [ $# = 0 ]; then
	cat /var/log/socklog/*/current | sort -u
	tail -Fq -n0 /var/log/socklog/*/current | uniq
else
	old=
	cur=
	for log; do
		case "$log" in
			-*) usage; exit 1;;
		esac
		if [ -d /var/log/socklog/$log ]; then
			old="$old /var/log/socklog/$log/*.[us]"
			cur="$cur /var/log/socklog/$log/current"
		else
			echo "no logs for $log" 1>&2
                        exit 1
		fi
	done
	cat $old $cur | sort
	tail -Fq -n0 $cur
fi