| #!/bin/bash |
| # Copyright 2018 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| #### CATEGORY=Run, inspect and debug |
| ### listen for logs. |
| |
| ## usage: fx syslog [--raw] [flags] |
| ## |
| ## Creates an SSH connection with a device and starts listening for logs. |
| ## Pass -h to get help with log-listener flags. |
| ## pass --raw as the first argument to get the raw, unsymbolized logs. |
| |
| set -o pipefail |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? |
| |
| function listen { |
| while true; do |
| fx-command-run wait || return |
| fx-command-run shell log_listener "$@" |
| echo "Connection lost, reconnecting..." |
| done |
| } |
| |
| for arg in "$@"; do |
| if [[ "$arg" = "-h" || "$arg" = "--help" ]]; then |
| fx-command-exec shell log_listener "$arg" |
| fi |
| done |
| |
| echo "Connecting..." |
| if [[ $# > 0 && "$1" = "--raw" ]]; then |
| shift |
| listen "$@" |
| else |
| listen "$@" | fx-symbolize |
| fi |