| #!/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. |
| |
| ### 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]}")" && pwd)"/lib/vars.sh |
| |
| function listen { |
| while true; do |
| fx-command-run wait || return |
| fx-command-run shell log_listener "$@" |
| echo "Connection lost, reconnecting..." |
| done |
| } |
| |
| echo "Connecting..." |
| if [[ $# > 0 && "$1" = "--raw" ]]; then |
| shift |
| listen "$@" |
| else |
| listen "$@" | fx-symbolize |
| fi |