support native mode in planoai logs command (#807)

This commit is contained in:
Adil Hafeez 2026-03-05 18:34:06 -08:00 committed by GitHub
parent 065328e11c
commit b9f01c8471
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 51 additions and 1 deletions

View file

@ -423,3 +423,41 @@ def native_validate_config(plano_config_file):
# Suppress verbose print output from config_generator
with contextlib.redirect_stdout(io.StringIO()):
validate_and_render_schema()
def native_logs(debug=False, follow=False):
"""Stream logs from native-mode Plano."""
import glob as glob_mod
log_dir = os.path.join(PLANO_RUN_DIR, "logs")
if not os.path.isdir(log_dir):
log.error(f"No native log directory found at {log_dir}")
log.error("Is Plano running? Start it with: planoai up <config.yaml>")
sys.exit(1)
log_files = sorted(glob_mod.glob(os.path.join(log_dir, "access_*.log")))
if debug:
log_files.extend(
[
os.path.join(log_dir, "envoy.log"),
os.path.join(log_dir, "brightstaff.log"),
]
)
# Filter to files that exist
log_files = [f for f in log_files if os.path.exists(f)]
if not log_files:
log.error(f"No log files found in {log_dir}")
sys.exit(1)
tail_args = ["tail"]
if follow:
tail_args.append("-f")
tail_args.extend(log_files)
try:
proc = subprocess.Popen(tail_args, stdout=sys.stdout, stderr=sys.stderr)
proc.wait()
except KeyboardInterrupt:
if proc.poll() is None:
proc.terminate()