Commit 99d398dd authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Small tweaks and formatting changes.

* also fix pep8 issue in associated test
parent 9813dd34
...@@ -276,14 +276,14 @@ class Archiver(): ...@@ -276,14 +276,14 @@ class Archiver():
if line['actor.email']: if line['actor.email']:
body = ('type=login,' body = ('type=login,'
'type={},' 'type={},'
'datetime={},' 'event_time={},'
'ip_address={}'.format( 'ip_address={}'.format(
line['name'], line['name'],
line['id.time'], line['id.time'],
line['ipAddress'] line['ipAddress']
)) ))
if line['parameters.2.boolValue']: if line['parameters.2.boolValue']:
body += 'suspicious={}'.format( body += ',suspicious={}'.format(
line['parameters.2.boolValue'] line['parameters.2.boolValue']
) )
self.logger.info( self.logger.info(
...@@ -463,8 +463,7 @@ Used with login reporting to account for inherant delay.''', ...@@ -463,8 +463,7 @@ Used with login reporting to account for inherant delay.''',
config = yaml.load(stream, Loader=yaml.BaseLoader) config = yaml.load(stream, Loader=yaml.BaseLoader)
# Oerride the default syslog format for this one. # Oerride the default syslog format for this one.
config['general']['log_format'] = ("level=%(levelname)s" config['general']['log_format'] = ("%(message)s,"
",%(message)s,"
"entity=%(entity)s" "entity=%(entity)s"
) )
...@@ -479,20 +478,10 @@ Used with login reporting to account for inherant delay.''', ...@@ -479,20 +478,10 @@ Used with login reporting to account for inherant delay.''',
) )
formatter = logging.Formatter( formatter = logging.Formatter(
config['general']['log_format'], config['general']['log_format'],
config['general']['log_date_format']
) )
sh.setFormatter(formatter) sh.setFormatter(formatter)
logger.addHandler(sh) logger.addHandler(sh)
# Create a console handler, set format, and associate.
ch = logging.StreamHandler()
formatter = logging.Formatter(
config['general']['console_format'],
config['general']['log_date_format']
)
ch.setFormatter(formatter)
logger.addHandler(ch)
if args.daily: if args.daily:
archiver = Archiver(vars(args), config) archiver = Archiver(vars(args), config)
userP = Process(target=archiver.log_users) userP = Process(target=archiver.log_users)
......
...@@ -14,6 +14,7 @@ archiver = archive_data.Archiver( ...@@ -14,6 +14,7 @@ archiver = archive_data.Archiver(
yaml.load(open(config), Loader=yaml.BaseLoader) yaml.load(open(config), Loader=yaml.BaseLoader)
) )
def test_log_users(): def test_log_users():
archiver.log_users() archiver.log_users()
logfile = archiver.data_dir + '/user.csv' logfile = archiver.data_dir + '/user.csv'
......
Supports Markdown
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