Skip to content

Add some new jazz to logtail#466

Merged
und1sk0 merged 5 commits intomasterfrom
SAN-4222-etudes-des-logs
May 12, 2016
Merged

Add some new jazz to logtail#466
und1sk0 merged 5 commits intomasterfrom
SAN-4222-etudes-des-logs

Conversation

@und1sk0
Copy link
Copy Markdown
Contributor

@und1sk0 und1sk0 commented May 11, 2016

  • lograw() - tail -f the raw logs
  • loglast() - tail the last N lines into bunyan where N = default for tail or number specified.
  • greplog() - tail -f the logs, searching for "${regexp}", piped into bunyan

Reviewers

Tests

Test any modifications on one of our environments.

  • tested on environment by someone

Deployment (post-merge)

Ensure that all environments have the given changes.

  • deployed to epsilon
  • deployed to gamma
  • deployed to delta

@und1sk0 und1sk0 added the review label May 11, 2016
@bkendall
Copy link
Copy Markdown
Contributor

is there any difference between those two files?

local app_name="$1"
local datetime=`date +%Y/%m/%d/%H`
local app_log_dir="{{ app_log_dir }}"
local logfile="${app_log_dir}/${datetime}/${app_name}.log"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like you're doing the above local assignments all over the place in this file. Perhaps you could make a command that determines the log file path for you? Then each of the functions would shrink. Here's how it might look:

logpath() {
  local app_name="$1"
  local datetime=`date +%Y/%m/%d/%H`
  local app_log_dir="{{ app_log_dir }}"
  echo "${app_log_dir}/${datetime}/${app_name}.log"
}

lograw() {
  tail -f "$(logpath $1)"
}

@rsandor
Copy link
Copy Markdown
Contributor

rsandor commented May 12, 2016

Left comment on refactoring. Also, I suggest avoiding the use of the function keyword in bash. These are technically commands, and using the function keyword makes it even more confusing for newbs. Example:

# This is bad
function stuff() { ... }

# This is good
stuff() { ... }

@@ -1,19 +1,51 @@
# 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)
# Usage: logtail <app_name>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments should be above the logtail command. Also add doc above logpath to explain what it will do.

# Usage: npmlog <app_name>
function npmlog() {
logtail() {
local app_name="$1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make these flexible and allow extra args to Bunyan?

$@

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd be awesome I'd love to logtail api-workers --level 40

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everyone's a critic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Myztiq @anandkumarpatel next rev gentlemen... until then you can tail -f $(logpath api) | bunyan [ <OPTS> ]

if [ 2 -eq "{{ '${#}' }}" ] ; then
tailopts="-${2}"
fi
tail ${tailopts} $(logpath ${app_name}) | bunyan
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use quotes around ${tailopts} and $(logpath ...)

@und1sk0 und1sk0 merged commit 46401da into master May 12, 2016
@und1sk0 und1sk0 deleted the SAN-4222-etudes-des-logs branch May 12, 2016 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants