Skip to content

PinionAI Logging Guide

This document provides instructions on how to access, read, and interpret the logs generated by the PinionAI Streamlit application and its underlying client library. Effective logging is crucial for debugging agent behavior, diagnosing errors, and monitoring the application's health.

Overview

The application uses Python's standard logging module. When running the application locally for testing (e.g., via 1_Test_Agent.py), logs are configured to be written to a file. When deployed to Google Cloud Run, these logs are automatically captured by Cloud Logging.

Log Location and Access

1. Local Development

When you run the application locally, a log file is created in the root directory of the project.

  • File Name: app.log
  • Location: /<application_path>/app.log

You can monitor the logs in real-time using a terminal command:

tail -f app.log

Alternatively, you can open the app.log file in any text editor to review its contents.

2. Google Cloud Run

When the application is deployed as a Cloud Run service, all output to standard output (stdout) and standard error (stderr), including our application logs, is automatically ingested by Google Cloud Logging.

To view the logs:

  1. Navigate to the Google Cloud Console.
  2. In the navigation menu, go to Logging > Log Explorer.
  3. In the query builder, you can filter for your specific Cloud Run service. Use a query like the following, replacing <YOUR_SERVICE_NAME> with the name you gave your service during deployment:

    resource.type="cloud_run_revision"
    resource.labels.service_name="<YOUR_SERVICE_NAME>"
    
  4. You can further filter by log severity (e.g., severity=ERROR) to quickly find problems.

Understanding the Log Format

Each log entry follows a consistent format:

TIMESTAMP - LOGGER_NAME - LOG_LEVEL - MESSAGE

Example:

2023-10-27 14:22:15,831 - pinionai.client - INFO - gRPC client connected to localhost:50051 for session <session_id> as user
  • 2023-10-27 14:22:15,831: The timestamp when the log was generated.
  • pinionai.client: The name of the logger. This helps identify which part of the code generated the message.
  • INFO: The log level, indicating the severity of the message.
  • gRPC client connected...: The actual log message.

Log Levels

  • DEBUG: Detailed, low-level information useful for in-depth debugging (e.g., Process Routing | {'api': 'Get_Customer'}).
  • INFO: Confirmation that things are working as expected (e.g., gRPC client connected..., Email sent to...).
  • WARNING: Indicates something unexpected happened, or a potential issue that doesn't prevent the current operation from completing (e.g., Could not list tools from MCP..., API ... failed with status 404...).
  • ERROR: A serious problem occurred, and the software was unable to perform a specific function (e.g., Error calling OpenAI API..., Failed to initialize PinionAI client...).

Key Log Messages to Look For

When troubleshooting, searching for these specific log messages can be very helpful:

  • Initialization:
  • pinionai.client - INFO - Initializing Gemini client...
  • pinionai.client - ERROR - Failed to initialize PinionAI client...
  • gRPC / Live Agent Chat:
  • pinionai.client - INFO - gRPC client connected to...
  • pinionai.client - INFO - gRPC message received...
  • pinionai.client - ERROR - Failed to start gRPC client...
  • Agent Processing Flow:
  • pinionai.client - DEBUG - Classification | <intent_name>
  • pinionai.client - DEBUG - Run API | <api_name>
  • pinionai.client - INFO - LLM requested to call function '<function_name>'...
  • Common Errors:
  • pinionai.client - WARNING - API ... failed with status ...
  • pinionai.client - ERROR - Error executing tool function...
  • pinionai.client - ERROR - Error calling <Provider> API for model ...