Skip to content

Commit

Permalink
Add log file level setup
Browse files Browse the repository at this point in the history
  • Loading branch information
soflc committed Sep 12, 2024
1 parent c51bc45 commit bcf749f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/pupil_labs/egocentric_video_mapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ def main(args=None):
help="Render video from alternative camera with gaze overlay.",
default=False,
)
parser.add_argument("--logging_level", default="INFO", help="Logging level")
parser.add_argument(
"--logging_level_stream",
default="ERROR",
help="Logging level for printing to console",
)
parser.add_argument(
"--logging_level_file",
default="INFO",
help="Logging level for saving to log file",
)

args = parser.parse_args()
try:
Expand All @@ -128,6 +137,12 @@ def main(args=None):
except AttributeError:
args.optic_flow_thrshld = None

# check if logging level exists
if not hasattr(args, "logging_level_stream"):
args.logging_level_stream = "WARNING"
if not hasattr(args, "logging_level_file"):
args.logging_level_file = "WARNING"

Path(args.output_dir).mkdir(parents=True, exist_ok=True)

stream_handler = logging.StreamHandler(sys.stdout)
Expand All @@ -147,7 +162,7 @@ def main(args=None):
stream_handler,
],
datefmt="%m/%d/%Y %I:%M:%S %p",
level=logging.INFO,
level=args.logging_level_file,
)
logger = logging.getLogger(__name__)
logger.info(
Expand Down Expand Up @@ -181,9 +196,9 @@ def main(args=None):
output_dir=args.output_dir,
matcher_choice=args.matcher,
optic_flow_method=args.optic_flow_choice,
logging_level="INFO",
logging_level=args.logging_level_file,
)
stream_handler.setLevel(args.logging_level)
stream_handler.setLevel(args.logging_level_stream)
mapper = EgocentricMapper(**mapper_kwargs)
gaze_csv_path = mapper.map_gaze(
refresh_time_thrshld=args.refresh_time_thrshld,
Expand Down

0 comments on commit bcf749f

Please sign in to comment.