Skip to content

Commit 7f8c8af

Browse files
author
Christopher M. Neill
committed
refactor
1 parent 11b1c3e commit 7f8c8af

3 files changed

Lines changed: 32 additions & 47 deletions

File tree

ansible/dock.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111

1212
- include: charon.yml git_branch="{{ charon_version }}"
1313
- include: dock-init.yml git_branch="{{ dock_init_version }}"
14-
- include: filibuster.yml git_branch="{{ filibuster_version }}"
1514
- include: image-builder.yml git_branch="{{ image_builder_version }}"
1615
- include: krain.yml git_branch="{{ krain_version }}"
Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,51 @@
11
# Follows the logfile for a given app_name interpolating the datetime string into the logpath (/var/log/runnable/YYYY/MM/DD/HH/<app_name>.log)
22
# Usage: logtail <app_name>
3-
function logtail() {
3+
4+
logpath() {
45
local app_name="$1"
56
local datetime=`date +%Y/%m/%d/%H`
67
local app_log_dir="{{ app_log_dir }}"
7-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
8-
tail -f ${logfile} | bunyan
8+
echo "${app_log_dir}/${datetime}/${app_name}.log"
9+
}
10+
11+
logtail() {
12+
local app_name="$1"
13+
tail -f $(logpath ${app_name}) | bunyan
914
}
1015

1116
# Follows the logfile for a given app_name interpolating the datetime string into the logpath (/var/log/runnable/YYYY/MM/DD/HH/<app_name>.log)
1217
# Usage: lograw <app_name>
13-
function lograw() {
18+
lograw() {
1419
local app_name="$1"
15-
local datetime=`date +%Y/%m/%d/%H`
16-
local app_log_dir="{{ app_log_dir }}"
17-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
18-
tail -f ${logfile}
20+
tail -f $(logpath ${app_name})
1921
}
2022

2123
# Just display the last few lines of a log (2nd arg specifies # of lines or tail default if left blank)
2224
# Usage: loglast <app_name> [ <#_of_lines> ]
23-
function loglast() {
25+
loglast() {
2426
local app_name="$1"
25-
local datetime=`date +%Y/%m/%d/%H`
26-
local app_log_dir="{{ app_log_dir }}"
27-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
2827
local tailopts=""
2928
# trusting YOU, the user, not to fsck this up
3029
if [ 2 -eq ${#} ] ; then
3130
tailopts="-${2}"
3231
fi
33-
tail ${tailopts} ${logfile} | bunyan
32+
tail ${tailopts} $(logpath ${app_name}) | bunyan
3433
}
3534
3635
# Follow a log, grep for "${regexp}"
3736
# Usage: greplog <app_name> <regexp>
38-
function greplog() {
37+
greplog() {
3938
local app_name="$1"
40-
local datetime=`date +%Y/%m/%d/%H`
41-
local app_log_dir="{{ app_log_dir }}"
42-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
4339
local regexp=""
4440
# trusting YOU, the user, not to fsck this up
4541
if [ 2 -eq ${#} ] ; then
4642
regexp="${2}"
4743
fi
48-
tail -f ${logfile} | grep ${regexp} | bunyan
44+
tail -f $(logpath ${app_name}) | grep ${regexp} | bunyan
4945
}
5046

5147
# Outputs contents of an npm start log for <app_name>, if it exists, into a pager for reading.
5248
# Usage: npmlog <app_name>
53-
function npmlog() {
54-
local app_name="$1"
55-
local app_log_dir="/var/log"
56-
local logfile="${app_log_dir}/${app_name}.log"
57-
less ${logfile}
49+
npmlog() {
50+
less $(logpath ${app_name})
5851
}
Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,51 @@
11
# Follows the logfile for a given app_name interpolating the datetime string into the logpath (/var/log/runnable/YYYY/MM/DD/HH/<app_name>.log)
22
# Usage: logtail <app_name>
3-
function logtail() {
3+
4+
logpath() {
45
local app_name="$1"
56
local datetime=`date +%Y/%m/%d/%H`
67
local app_log_dir="{{ app_log_dir }}"
7-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
8-
tail -f ${logfile} | bunyan
8+
echo "${app_log_dir}/${datetime}/${app_name}.log"
9+
}
10+
11+
logtail() {
12+
local app_name="$1"
13+
tail -f $(logpath ${app_name}) | bunyan
914
}
1015

1116
# Follows the logfile for a given app_name interpolating the datetime string into the logpath (/var/log/runnable/YYYY/MM/DD/HH/<app_name>.log)
1217
# Usage: lograw <app_name>
13-
function lograw() {
18+
lograw() {
1419
local app_name="$1"
15-
local datetime=`date +%Y/%m/%d/%H`
16-
local app_log_dir="{{ app_log_dir }}"
17-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
18-
tail -f ${logfile}
20+
tail -f $(logpath ${app_name})
1921
}
2022

2123
# Just display the last few lines of a log (2nd arg specifies # of lines or tail default if left blank)
2224
# Usage: loglast <app_name> [ <#_of_lines> ]
23-
function loglast() {
25+
loglast() {
2426
local app_name="$1"
25-
local datetime=`date +%Y/%m/%d/%H`
26-
local app_log_dir="{{ app_log_dir }}"
27-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
2827
local tailopts=""
2928
# trusting YOU, the user, not to fsck this up
3029
if [ 2 -eq ${#} ] ; then
3130
tailopts="-${2}"
3231
fi
33-
tail ${tailopts} ${logfile} | bunyan
32+
tail ${tailopts} $(logpath ${app_name}) | bunyan
3433
}
3534
3635
# Follow a log, grep for "${regexp}"
3736
# Usage: greplog <app_name> <regexp>
38-
function greplog() {
37+
greplog() {
3938
local app_name="$1"
40-
local datetime=`date +%Y/%m/%d/%H`
41-
local app_log_dir="{{ app_log_dir }}"
42-
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
4339
local regexp=""
4440
# trusting YOU, the user, not to fsck this up
4541
if [ 2 -eq ${#} ] ; then
4642
regexp="${2}"
4743
fi
48-
tail -f ${logfile} | grep ${regexp} | bunyan
44+
tail -f $(logpath ${app_name}) | grep ${regexp} | bunyan
4945
}
5046

5147
# Outputs contents of an npm start log for <app_name>, if it exists, into a pager for reading.
5248
# Usage: npmlog <app_name>
53-
function npmlog() {
54-
local app_name="$1"
55-
local app_log_dir="/var/log"
56-
local logfile="${app_log_dir}/${app_name}.log"
57-
less ${logfile}
49+
npmlog() {
50+
less $(logpath ${app_name})
5851
}

0 commit comments

Comments
 (0)