Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dtable_events/app/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def _rotating_config(self):
def _basic_config(self):
# Log to stdout. Mainly for development.
kw = {
'format': '[%(asctime)s] %(filename)s[line:%(lineno)d] [%(levelname)s] %(message)s',
'datefmt': '%m/%d/%Y %H:%M:%S',
'format': '[%(asctime)s] [%(levelname)s] %(filename)s[line:%(lineno)d] %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S',
'level': self._level,
'stream': sys.stdout
}
Expand Down
9 changes: 7 additions & 2 deletions dtable_events/dtable_io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ def setup_logger(logname):
"""
logdir = os.path.join(os.environ.get('LOG_DIR', ''))
log_file = os.path.join(logdir, logname)
handler = handlers.TimedRotatingFileHandler(log_file, when='MIDNIGHT', interval=1, backupCount=7)
formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')

if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
handler = logging.StreamHandler(sys.stdout)
else:
handler = handlers.TimedRotatingFileHandler(log_file, when='MIDNIGHT', interval=1, backupCount=7)

formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
handler.setFormatter(formatter)
handler.addFilter(logging.Filter(logname))

Expand Down
8 changes: 6 additions & 2 deletions dtable_events/tasks/dtable_rows_counter.py
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the class DTableRowsCounter is not used anymore?

I could not find any references to it in the codebase.

Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ def run(self):
manage_py,
'count_user_org_rows'
]
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)

if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
run(cmd, cwd=dtable_web_dir)
else:
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)
except Exception as e:
logging.exception('error when counting rows: %s', e)

Expand Down
8 changes: 6 additions & 2 deletions dtable_events/tasks/dtable_updates_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ def run(self):
manage_py,
'send_dtable_updates',
]
with open(self._logfile, 'a') as fp:
run_and_wait(cmd, cwd=dtable_web_dir, output=fp)

if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
run_and_wait(cmd, cwd=dtable_web_dir)
else:
with open(self._logfile, 'a') as fp:
run_and_wait(cmd, cwd=dtable_web_dir, output=fp)
except Exception as e:
logging.exception('send dtable updates email error: %s', e)

Expand Down
7 changes: 5 additions & 2 deletions dtable_events/tasks/dtables_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ def run(self):
'clean_trash_dtables',
self._expire_seconds,
]
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)
if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
run(cmd, cwd=dtable_web_dir)
else:
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)
except Exception as e:
logging.exception('error when cleaning trash dtables: %s', e)

Expand Down
8 changes: 6 additions & 2 deletions dtable_events/tasks/email_notices_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def run(self):
manage_py,
'send_email_notices',
]
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)

if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
run(cmd, cwd=dtable_web_dir)
else:
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)
except Exception as e:
logging.exception('error when send email: %s', e)

Expand Down
7 changes: 5 additions & 2 deletions dtable_events/tasks/instant_notices_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ def run(self):
'send_instant_notices',
]

with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)
if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
run(cmd, cwd=dtable_web_dir)
else:
with open(self._logfile, 'a') as fp:
run(cmd, cwd=dtable_web_dir, output=fp)
except Exception as e:
logging.exception('send instant notices error: %s', e)

Expand Down
8 changes: 6 additions & 2 deletions dtable_events/tasks/ldap_syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ def run(self):
manage_py,
'ldap_group_sync'
]
with open(self._logfile, 'a') as fp:
run_and_wait(cmd, cwd=dtable_web_dir, output=fp)

if os.environ.get('SEATABLE_LOG_TO_STDOUT', 'false').lower() == 'true':
run_and_wait(cmd, cwd=dtable_web_dir)
else:
with open(self._logfile, 'a') as fp:
run_and_wait(cmd, cwd=dtable_web_dir, output=fp)
except Exception as e:
logging.exception('error when sync ldap group: %s', e)

Expand Down
Loading