Skip to content

Commit 166e6e1

Browse files
committed
move logs to 1 or 2. If 3 is used, we will also see SHM logs
1 parent 994248d commit 166e6e1

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

mlapi.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def post(self):
129129

130130
for key in g.monitor_config[mid]:
131131
# This will also take care of copying over mid specific stream_options
132-
g.logger.Debug(4, 'Overriding global {} with {}...'.format(key, g.monitor_config[mid][key][:30]))
132+
g.logger.Debug(2, 'Overriding global {} with {}...'.format(key, g.monitor_config[mid][key][:30]))
133133
g.config[key] = g.monitor_config[mid][key]
134134

135135
# stupid mlapi and zm_detect config incompatibility
@@ -141,12 +141,12 @@ def post(self):
141141

142142
r = req.get('reason')
143143
if r and g.config['only_triggered_zm_zones'] == 'yes' and g.config['import_zm_zones'] == 'yes':
144-
g.logger.Debug(4, 'Only filtering polygon names that have {}'.format(r))
144+
g.logger.Debug(2, 'Only filtering polygon names that have {}'.format(r))
145145
r =r.replace(' ','_').lower()
146-
g.logger.Debug(4, 'Original polygons being used: {}'.format(g.polygons))
146+
g.logger.Debug(2, 'Original polygons being used: {}'.format(g.polygons))
147147

148148
g.polygons[:] = [item for item in g.polygons if utils.findWholeWord(item['name'])(r)]
149-
g.logger.Debug(4, 'Final polygons being used: {}'.format(g.polygons))
149+
g.logger.Debug(2, 'Final polygons being used: {}'.format(g.polygons))
150150

151151

152152
if g.config['ml_sequence'] and g.config['use_sequence'] == 'yes':
@@ -160,8 +160,7 @@ def post(self):
160160
g.logger.Debug(2,'mapping legacy ml data from config')
161161
ml_options = utils.convert_config_to_ml_sequence()
162162

163-
g.logger.Debug (4, 'Overwriting ml_sequence of pre loaded model')
164-
#g.logger.Debug (4, "REMOVE ME: NEW CONFIG: TYPE:{} ==> {}".format(type(ml_options), ml_options))
163+
g.logger.Debug (2, 'Overwriting ml_sequence of pre loaded model')
165164
m.set_ml_options(ml_options)
166165
else:
167166
g.logger.Debug(1,'Monitor ID not specified, or not found in mlapi config, using zm_detect overrides')
@@ -180,7 +179,7 @@ def post(self):
180179
#print (ml_options)
181180

182181
if g.config.get('stream_sequence'):
183-
g.logger.Debug(4, 'Found stream_sequence in mlapi config, ignoring objectconfig.ini')
182+
g.logger.Debug(2, 'Found stream_sequence in mlapi config, ignoring objectconfig.ini')
184183
stream_options = ast.literal_eval(g.config.get('stream_sequence'))
185184
else:
186185
stream_options = req.get('stream_options')
@@ -232,7 +231,7 @@ def post(self):
232231
oldw = matched_data['image_dimensions']['original'][1]
233232

234233
if config_copy:
235-
g.log.Debug(4, 'Restoring global config & ml_options')
234+
g.log.Debug(2, 'Restoring global config & ml_options')
236235
g.config = config_copy
237236
g.polygons = poly_copy
238237

@@ -375,8 +374,6 @@ def ret_val(exception):
375374
else:
376375
zmapi = zmapi.ZMApi(options=api_options)
377376
utils.check_and_import_zones(zmapi)
378-
#g.logger.Debug (4, 'REMOVEME: FULL LIST OF ZONES IMPORTED: {}'.format (g.monitor_polygons))
379-
380377

381378

382379
ml_options = {}

modules/utils.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def check_and_import_zones(api):
3737

3838
# if we have a 'no' inside local monitor section, don't import
3939
if mid in g.monitor_config and g.monitor_config[mid].get('import_zm_zones') == 'no':
40-
g.logger.Debug(4,'Not importing zones for monitor:{} as the monitor specific section says no'.format(mid))
40+
g.logger.Debug(1,'Not importing zones for monitor:{} as the monitor specific section says no'.format(mid))
4141
continue
4242
# else if global is no, and there is no local, don't import
4343
elif g.config['import_zm_zones'] == 'no' and (mid not in g.monitor_config or not g.monitor_config[mid].get('import_zm_zones')):
44-
g.logger.Debug(4,'Not importing zone:{} for monitor:{} as the global setting says no and there is no local override'.format(item['Zone']['Name'], mid))
44+
g.logger.Debug(1,'Not importing zone:{} for monitor:{} as the global setting says no and there is no local override'.format(item['Zone']['Name'], mid))
4545
continue
4646

4747
# At this stage, global is 'yes' and local is either unspecified or has 'yes'
@@ -51,7 +51,7 @@ def check_and_import_zones(api):
5151
g.monitor_polygons[mid] = []
5252

5353
if item['Zone']['Type'] == 'Inactive':
54-
g.logger.Debug(2, 'Skipping {} as it is inactive'.format(item['Zone']['Name']))
54+
g.logger.Debug(1, 'Skipping {} as it is inactive'.format(item['Zone']['Name']))
5555
continue
5656

5757
item['Zone']['Name'] = item['Zone']['Name'].replace(' ','_').lower()
@@ -299,13 +299,13 @@ def _set_config_val(k,v):
299299
ml = config_file.get('ml', 'ml_sequence')
300300
g.monitor_config[mid]['ml_sequence']=ml
301301
except:
302-
g.logger.Debug (4, 'ml sequence not found in globals')
302+
g.logger.Debug (2, 'ml sequence not found in globals')
303303

304304
try:
305305
ss = config_file.get('ml', 'stream_sequence')
306306
g.monitor_config[mid]['stream_sequence']=ss
307307
except:
308-
g.logger.Debug (4, 'stream sequence not found in globals')
308+
g.logger.Debug (2, 'stream sequence not found in globals')
309309

310310
for item in config_file[sec].items():
311311
k = item[0]
@@ -318,7 +318,7 @@ def _set_config_val(k,v):
318318
else:
319319
if k in g.config_vals:
320320
# This means its a legit config key that needs to be overriden
321-
g.logger.Debug(4,'[{}] overrides key:{} with value:{}'.format(sec, k, v))
321+
g.logger.Debug(2,'[{}] overrides key:{} with value:{}'.format(sec, k, v))
322322
g.monitor_config[mid][k]=_correct_type(v,g.config_vals[k]['type'])
323323
# g.monitor_config[mid].append({ 'key':k, 'value':_correct_type(v,g.config_vals[k]['type'])})
324324
else:
@@ -343,16 +343,14 @@ def _set_config_val(k,v):
343343
if k in g.config_vals:
344344
_set_config_val(k,g.config_vals[k] )
345345
else:
346-
#g.logger.Debug(4, 'storing unknown attribute {}={}'.format(k,v))
347346
g.config[k] = v
348-
#_set_config_val(k,{'section': sec, 'default': None, 'type': 'string'} )
349347

350348

351349

352350

353351
# Parameter substitution
354352

355-
g.logger.Debug (4,'Doing parameter substitution for globals')
353+
g.logger.Debug (2,'Doing parameter substitution for globals')
356354
p = r'{{(\w+?)}}'
357355
for gk, gv in g.config.items():
358356
#input ('Continue')
@@ -369,11 +367,11 @@ def _set_config_val(k,v):
369367
g.config[gk] = new_val
370368
gv = new_val
371369
else:
372-
g.logger.Debug(4, 'substitution key: {} not found'.format(match_key))
370+
g.logger.Debug(2, 'substitution key: {} not found'.format(match_key))
373371
if not replaced:
374372
break
375373

376-
g.logger.Debug (4,'Doing parameter substitution for monitor specific entities')
374+
g.logger.Debug (2,'Doing parameter substitution for monitor specific entities')
377375
p = r'{{(\w+?)}}'
378376
for mid in g.monitor_config:
379377
for key in g.monitor_config[mid]:
@@ -398,7 +396,7 @@ def _set_config_val(k,v):
398396
gv = new_val
399397
g.monitor_config[mid][key] = gv
400398
else:
401-
g.logger.Debug(4, 'substitution key: {} not found'.format(match_key))
399+
g.logger.Debug(2, 'substitution key: {} not found'.format(match_key))
402400
if not replaced:
403401
break
404402

0 commit comments

Comments
 (0)