Skip to content

Commit

Permalink
Adding support for logging messages at specified level
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Jun 14, 2021
1 parent df70534 commit faa327d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions tardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def run_tardis(
simulation_callbacks=[],
virtual_packet_logging=False,
log_state="Critical",
specific=False,
):
"""
This function is one of the core functions to run TARDIS from a given
Expand All @@ -32,9 +33,7 @@ def run_tardis(
-------
Simulation
"""
from tardis.montecarlo.montecarlo_numba.montecarlo_logger import (
logging_state,
)
from tardis import logging_state
from tardis.io.config_reader import Configuration
from tardis.io.atom_data.base import AtomData
from tardis.simulation import Simulation
Expand All @@ -47,19 +46,24 @@ def run_tardis(
except TypeError:
tardis_config = Configuration.from_config_dict(config)

if specific or tardis_config["debug"]["specific_logging"]:
specific = True
else:
specific = False

if tardis_config["debug"]["logging_level"] or log_state:
if (
log_state.upper() == "CRITICAL"
and tardis_config["debug"]["logging_level"]
):
logging_state(tardis_config["debug"]["logging_level"])
logging_state(tardis_config["debug"]["logging_level"], specific)
elif log_state:
logging_state(log_state)
logging_state(log_state, specific)
if tardis_config["debug"]["logging_level"] and log_state:
print("Log_state & logging_level both specified")
print("Log_state will be used for Log Level Determination\n")
else:
logging_state(tardis_config["debug"]["logging_level"])
logging_state(tardis_config["debug"]["logging_level"], specific)

if atom_data is not None:
try:
Expand Down
6 changes: 5 additions & 1 deletion tardis/io/schemas/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ properties:
logging_level:
type: string
default: "Info"
description: Sets the Logging Level for the logger
description: Sets the logging Level for the logger
properties:
type:
enum:
Expand All @@ -15,6 +15,10 @@ properties:
- "Warning"
- "Error"
- "Critical"
specific_logging:
type: boolean
default: false
description: Allows for logging on the specified level logs
# debug_packets:
# type: boolean
# default: false
Expand Down

0 comments on commit faa327d

Please sign in to comment.