Skip to content

Commit

Permalink
more explicit paramiko logging cuz we are getting nowhere fast with t…
Browse files Browse the repository at this point in the history
…his networking problem
  • Loading branch information
GondekNP committed Jan 5, 2024
1 parent 3799db2 commit 0dd4742
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/util/sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import io
import os
import tempfile

import logging
from google.cloud import logging as cloud_logging

class SFTPClient:
def __init__(self, hostname, username, private_key, port=22):
Expand All @@ -18,7 +19,17 @@ def __init__(self, hostname, username, private_key, port=22):

self.available_cogs = None

print(f"Initialized SFTPClient for {self.hostname} as {self.username}")
# Set up logging
logging_client = cloud_logging.Client()
log_name = "burn-backend"
self.logger = logging_client.logger(log_name)

# Route Paramiko logs to Google Cloud Logging
paramiko_logger = logging.getLogger("paramiko")
paramiko_logger.setLevel(logging.DEBUG)
paramiko_logger.addHandler(cloud_logging.handlers.CloudLoggingHandler(logging_client, name=log_name))

self.logger.log_text(f"Initialized SFTPClient for {self.hostname} as {self.username}")

def connect(self):
"""Connects to the sftp server and returns the sftp connection object"""
Expand Down

0 comments on commit 0dd4742

Please sign in to comment.