Skip to content

Commit 3ce1d91

Browse files
committed
Added defensive code to guard against monitors not passing
global config.
1 parent a99f6c4 commit 3ce1d91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scalyr_agent/scalyr_monitor.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,18 @@ def _get_log_rotation_configuration( self ):
272272

273273
rotation_count = self._config.get( "log_rotation_backup_count" )
274274
if rotation_count is None:
275-
rotation_count = self._global_config.log_rotation_backup_count
275+
# Sometimes global_config can be null if derived monitor did not pass one in.
276+
if self._global_config is not None:
277+
rotation_count = self._global_config.log_rotation_backup_count
278+
else:
279+
rotation_count = 2
276280

277281
max_bytes = self._config.get( "log_rotation_max_bytes" )
278282
if max_bytes is None:
279-
max_bytes = self._global_config.log_rotation_max_bytes
283+
if self._global_config is not None:
284+
max_bytes = self._global_config.log_rotation_max_bytes
285+
else:
286+
max_bytes = 20 * 1024 * 1024
280287

281288
return (rotation_count, max_bytes)
282289

0 commit comments

Comments
 (0)