blob: 34d7bb925ed7e4d80210ed20306c3c7ffc665ab7 [file] [log] [blame]
#!/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]}")" >/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
}
echo "Connecting..."
if [[ $# > 0 && "$1" = "--raw" ]]; then
shift
listen "$@"
else
listen "$@" | fx-symbolize
fi