Skip to content

Commit badab80

Browse files
Allow apps to change logging level (#66)
* Allow apps to change logging level * Make default INFO * Fix
1 parent ddb59d4 commit badab80

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

sample_apps/advanced_example_py/advanced_example1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def jrtc_start_app(capsule):
149149

150150
# Initialize the app
151151
state = AppStateVars(agg_cnt=0, app=None)
152-
state.app = jrtc_app_create(capsule, app_cfg, app_handler, state)
152+
state.app = jrtc_app_create(capsule, app_cfg, app_handler, state, log_level="INFO")
153153

154154
# run the app - This is blocking until the app exits
155155
jrtc_app_run(state.app)

sample_apps/advanced_example_py/advanced_example2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def jrtc_start_app(capsule):
140140

141141
# Initialize the app
142142
state = AppStateVars(agg_cnt=0, received_counter=0, app=None)
143-
state.app = jrtc_app_create(capsule, app_cfg, app_handler, state)
143+
state.app = jrtc_app_create(capsule, app_cfg, app_handler, state, log_level="INFO")
144144

145145
# run the app - This is blocking until the app exists
146146
jrtc_app_run(state.app)

sample_apps/first_example_py/first_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def jrtc_start_app(capsule):
111111

112112
# Initialize the app
113113
state = AppStateVars(agg_cnt=0, received_counter=0, app=None)
114-
state.app = jrtc_app_create(capsule, app_cfg, app_handler, state)
114+
state.app = jrtc_app_create(capsule, app_cfg, app_handler, state, log_level="INFO")
115115

116116
# run the app - This is blocking until the app exists
117117
jrtc_app_run(state.app)

src/wrapper_apis/python/jrtc_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,13 @@ def dump_stream_id(data):
120120

121121

122122
class JrtcApp:
123-
def __init__(self, env_ctx, app_cfg, app_handler, app_state):
123+
def __init__(self, env_ctx, app_cfg, app_handler, app_state, log_level = "INFO"):
124124
super().__init__()
125125
self.data = JrtcAppData(
126126
env_ctx, app_cfg, app_handler, app_state, time.monotonic()
127127
)
128128
self.stream_items: list[StreamItem] = []
129129
self.logger = logging.getLogger("jrtc_app")
130-
log_level = os.environ.get("JRTC_APP_LOG_LEVEL", "DEBUG").upper()
131130
logging.basicConfig(
132131
level=getattr(logging, log_level, logging.DEBUG),
133132
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
@@ -311,13 +310,14 @@ def get_chan_ctx(self, stream_idx: int) -> Optional[ChannelCtx]:
311310
return self.stream_items[stream_idx].chan_ctx
312311

313312

314-
def jrtc_app_create(capsule, app_cfg: JrtcAppCfg_t, app_handler, app_state):
313+
def jrtc_app_create(capsule, app_cfg: JrtcAppCfg_t, app_handler, app_state, log_level="INFO") -> JrtcApp:
315314
env_ctx = get_ctx_from_capsule(capsule)
316315
app_instance = JrtcApp(
317316
env_ctx=env_ctx,
318317
app_cfg=app_cfg,
319318
app_handler=app_handler,
320319
app_state=app_state,
320+
log_level=log_level,
321321
)
322322
return app_instance
323323

0 commit comments

Comments
 (0)