Skip to content

Commit

Permalink
Merge pull request #203 from PyFixate/diagnostic-log-argument
Browse files Browse the repository at this point in the history
Diagnostic log argument
  • Loading branch information
clint-lawrence authored Jul 23, 2024
2 parents 70020f4 + 9daa000 commit 791e336
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/fixate/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from importlib.machinery import SourceFileLoader
from zipimport import zipimporter
from pubsub import pub
from pathlib import Path
import fixate.config
from fixate.core.exceptions import SequenceAbort
from fixate.core.ui import user_info_important, user_serial, user_ok
Expand Down Expand Up @@ -38,14 +39,14 @@ def get_parser():
)

# Optional Arguments
mutex_group = parser.add_mutually_exclusive_group()
mutex_group.add_argument(
script_group = parser.add_mutually_exclusive_group(required=True)
script_group.add_argument(
"-p",
"--path",
help="""Path to the directory where the script file is located.
This is mutually exclusive with --zip""",
)
mutex_group.add_argument(
script_group.add_argument(
"-z",
"--zip",
help="""Path to zip file of test scripts. Mutually exclusive with --path""",
Expand Down Expand Up @@ -118,9 +119,16 @@ def get_parser():
action="store_true",
help="The sequencer will not prompt for retries.",
)
parser.add_argument(
diagnostic_group = parser.add_mutually_exclusive_group()
diagnostic_group.add_argument(
"--disable-logs", action="store_true", help="Turn off diagnostic logs"
)
diagnostic_group.add_argument(
"--diagnostic-log-dir",
default=fixate.config.LOG_DIRECTORY,
type=Path,
help="Directory to store the diagnostic log",
)

return parser

Expand Down Expand Up @@ -399,10 +407,10 @@ def run_main_program(test_script_path=None, main_args=None):
parser = get_parser()
args, unknown = parser.parse_known_args(args=main_args)
if not args.disable_logs:
fixate.config.LOG_DIRECTORY.mkdir(parents=True, exist_ok=True)
args.diagnostic_log_dir.mkdir(parents=True, exist_ok=True)

handler = RotateEachInstanceHandler(
fixate.config.LOG_DIRECTORY / "fixate.log", backupCount=10
args.diagnostic_log_dir / "fixate.log", backupCount=10
)
handler.setFormatter(
logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
Expand Down

0 comments on commit 791e336

Please sign in to comment.