Cannot see output in a lib python file

I have created a python file inside the lib folder. However, I cannot see the output of the log file. Are there any additional steps that I need to take to see the output of the log file. restarting the frontend is not helping.


Hey @haarisjalal thanks for reaching out on the forum with this issue! Can you just clarify the issue a little bit more? E.g. What’s the python file doing (maybe send a snippet of the code in case it’s helpful)? Which log file are you trying to see the output for? What is it you’re trying to achieve?

1 Like

So, I extracted some information and I created a redis table. Inside the lib file, I want to extract the redis table and do some adjustments to the extracted data. The extracted information (after some adjustments) will go in the integration file and eventually the front end.
However, I would like to see the logs to see what is actually happening when I am changing the file.

import redis
from redis import ResponseError
from configparser import NoOptionError, NoSectionError
import json
import sys
import threading

import logging
import requests

from squirro_client import SquirroClient, AuthenticationError

from axislib.config.redis_db import REDIS_DB_MAPPING, REDIS_DB_APPS_PURPOSES

from axislib.utils import get_credentials
from axislib.utils import GetRedisClient

from axislib.utils.constants import TNM_CRM_LOG, SOURCE_MAPPING_ITEM_UPLOADER

log = logging.getLogger(__name__)

CLIENT_HIERARCHY_KEY = 'client_hierarchy'

class GetClientHierarchy(object):
    Responsible for the extracting the data from Redis and josinify data. Configured with

    def __init__(self, squirro_client=None, project_id=None):
        self.sq_client = squirro_client
        self.project_id = project_id
        self.redis_client = GetRedisClient()

    def retrieve_hierarchy(self, query):
        Get the information and return it in JSON format
        {ultimate_parent:<ultimate_parent_name>, parent:[<parent_name1, parent_name2], account:<account_name>}

        # Obtain the data from Redis and get the collection value
        client_hierarchy_dict = self.redis_client.get_redis_entry(CLIENT_HIERARCHY_KEY)
        #client_hierarchy_dict = client_hierarchy_dict.get('collection')

At the moment, I just want to see the output of the log file, but I can’t see it in squirro_tail_logs. If I can just see the output, then I can go forward.

1 Like

Hi @haarisjalal :wave:

  • How are you running this script?
  • Are you running it directly on the server where Squirro is installed?
1 Like

yes, I am running it directly on the server

How are you running it? The code above defines a Python class but you don’t show how you are using the GetClientHierarchy class.

1 Like

oh crap. I forgot to import it in the integration file. I’ll try doing that first.