From 7327354df4786915c698c666ce41327f18708203 Mon Sep 17 00:00:00 2001 From: chandanchowdhury Date: Wed, 1 May 2024 15:14:38 -0400 Subject: [PATCH] feat: adding logging config parameter Signed-off-by: chandanchowdhury --- cartography/cli.py | 9 +++++++++ cartography/config.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/cartography/cli.py b/cartography/cli.py index 95c12a64d7..5ee4fa35a6 100644 --- a/cartography/cli.py +++ b/cartography/cli.py @@ -1,6 +1,7 @@ import argparse import getpass import logging +import logging.config import os import sys from typing import Optional @@ -111,6 +112,14 @@ def _build_parser(self): 'See https://neo4j.com/docs/api/python-driver/4.4/api.html#database.' ), ) + parser.add_argument( + '--logging-config', + type=str, + default=None, + help=( + 'Path to file containing Python logging configuration' + ), + ) parser.add_argument( '--selected-modules', type=str, diff --git a/cartography/config.py b/cartography/config.py index 5ea9cee002..d12858c752 100644 --- a/cartography/config.py +++ b/cartography/config.py @@ -19,6 +19,8 @@ class Config: :param neo4j_database: The name of the database in Neo4j to connect to. If not specified, uses your Neo4j database settings to infer which database is set to default. See https://neo4j.com/docs/api/python-driver/4.4/api.html#database. Optional. + :type logging_config: str + :param logging_config: Path to the file containing logging configuration. :type selected_modules: str :param selected_modules: Comma-separated list of cartography top-level modules to sync. Optional. :type update_tag: int @@ -120,6 +122,7 @@ def __init__( neo4j_password=None, neo4j_max_connection_lifetime=None, neo4j_database=None, + logging_config=None, selected_modules=None, update_tag=None, aws_sync_all_profiles=False, @@ -176,6 +179,7 @@ def __init__( self.neo4j_password = neo4j_password self.neo4j_max_connection_lifetime = neo4j_max_connection_lifetime self.neo4j_database = neo4j_database + self.logging_config - logging_config self.selected_modules = selected_modules self.update_tag = update_tag self.aws_sync_all_profiles = aws_sync_all_profiles