Implement events logging feature
Record events (i.e. pluginhook's calls) as syslog entries and provide a shortcut command to display the last part of the log file. A brief summary of the changes follows: dokku: - New DOKKU_EVENTS_LOGFILE envvar to hold logfile location. plugins/20_events/commands: - events output log entries, a tail's follow-like mode is provided too. - events:[on|off] enables/disables logging. - events:list lists events that are logged. plugins/20_events/hook: - Generic hook that writes log entries. All the events are registered via symlink to this script. plugins/common/functions: - dokku_log_event() writes log entries via logger. - dokku_log_pluginhook_call() formats log entries and writes them via dokku_log_event().
This commit is contained in:
20
plugins/20_events/install
Executable file
20
plugins/20_events/install
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$(dirname $0)/../common/functions"
|
||||
|
||||
if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then
|
||||
touch "$DOKKU_EVENTS_LOGFILE"
|
||||
# chown syslog:root might not work on SUSE
|
||||
chown syslog:dokku "$DOKKU_EVENTS_LOGFILE"
|
||||
chmod 664 "$DOKKU_EVENTS_LOGFILE"
|
||||
fi
|
||||
|
||||
if [[ ! -f "$DOKKU_RSYSLOG_FILTER" ]]; then
|
||||
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
|
||||
:syslogtag, contains, "dokku" $DOKKU_EVENTS_LOGFILE
|
||||
EOF
|
||||
service rsyslog reload
|
||||
|
||||
[[ "$DOKKU_EVENTS" ]] && dokku_log_pluginhook_call "$(basename $0)" $@
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user