Commit 3585cb3b authored by Trevor Cappallo's avatar Trevor Cappallo
Browse files

remove log/date/ directories

parent 3520f013
......@@ -35,6 +35,12 @@ class OperationalLogger:
"""Main class for Operational Logging."""
DEFAULT_LOG_FORMAT_FILE = '[%(asctime)s][%(levelname)5s][p%(process)d][%(filename)s:%(lineno)d] %(message)s'
DEFAULT_LOG_FORMAT_CONSOLE = '%(asctime)s (%(levelname)5s) [%(filename)s:%(lineno)d] %(message)s'
DEFAULT_DATE_FORMAT_FILE = '%Y-%m-%d %H:%M:%S'
DEFAULT_DATE_FORMAT_CONSOLE = '%H:%M:%S'
DEFAULT_FROM_ADDRESS = 'no-reply@aer.com'
# logger = OperationalLogger(
# log_filename=os.path.join(log_directory, log_filename), logger_name=logger_name,
# from_address=from_address, notify=notify, log_level=log_level, console_level=console_level,
......@@ -52,15 +58,15 @@ class OperationalLogger:
self.__error_buffer = StringIO.StringIO()
self.__critical_buffer = StringIO.StringIO()
if log_format_file is None:
log_format_file = '[%(asctime)s][%(levelname)5s][p%(process)d][%(filename)s:%(lineno)d] %(message)s'
log_format_file = self.DEFAULT_LOG_FORMAT_FILE
if log_format_console is None:
log_format_console = '%(asctime)s (%(levelname)5s) [%(filename)s:%(lineno)d] %(message)s'
log_format_console = self.DEFAULT_LOG_FORMAT_CONSOLE
if date_format_file is None:
date_format_file = '%Y-%m-%d %H:%M:%S'
date_format_file = self.DEFAULT_DATE_FORMAT_FILE
if date_format_console is None:
date_format_console = '%H:%M:%S'
date_format_console = self.DEFAULT_DATE_FORMAT_CONSOLE
if from_address is None:
from_address = 'no-reply@aer.com'
from_address = self.DEFAULT_FROM_ADDRESS
logging.basicConfig(filename=log_filename, format=log_format_file, datefmt=date_format_file, level=logging.DEBUG)
formatter = logging.Formatter(fmt=log_format_console, datefmt=date_format_console)
......@@ -161,13 +167,14 @@ def setup(config_file=None, logger_name=None, log_filename=None, log_root_dir=No
log_filename = os.path.basename(sys.argv[0]).split('.')[0] + '.log'
if not log_root_dir:
log_root_dir = os.getcwd()
log_directory = os.path.join(log_root_dir, 'log', datetime.datetime.utcnow().strftime('%Y-%m-%d'))
# log_directory = os.path.join(log_root_dir, 'log', datetime.datetime.utcnow().strftime('%Y-%m-%d'))
log_directory = os.path.abspath(log_root_dir)
if not os.path.exists(log_directory):
try:
# default log dir permissions: SGID bit + rwxr-x---
os.makedirs(log_directory, 02750)
except OSError:
logging.warn('Unable to create log directory %s', log_directory)
raise RuntimeError('Unable to create log directory: {}'.format(log_directory))
if notify is None:
notify = {}
if logger_name is None:
......@@ -280,8 +287,6 @@ def stack_trace(log_level=logging.ERROR):
if __name__ == '__main__':
#default_logging(addresses=['tcappallo@veriskclimate.com'], from_address='tcappallo@veriskclimate.com')
#default_logging(addresses=['msze@veriskclimate.com', 'msze@aer.com'], from_address='tcappallo@veriskclimate.com')
setup()
test = """Blah
foo
......@@ -293,11 +298,8 @@ if __name__ == '__main__':
logging.debug('Fin')
logging.error('An error in testing, oh, no!!')
logging.critical('Put up the Jimsignal!')
#long_error(test)
logging.error(test)
#c = ['find', '.', '-name', '*.py']
c = ['diff', 'a', 'b']
#logged_subprocess(c)
log_shell(c)
try:
raise Exception("I AM ERROR.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment