Ejemplo n.º 1
0
def main():
    # General simulation behavior is defined using command line arguments
    exit_status = 0
    args = setup.parse_commandline()
    loglevel = os.environ.get('LOG', 'warning')
    logfile = setup.logfile(args['session'])
    # Setup structured logs with file and stdout support
    log_setup = dna.logging.setup(
        level=loglevel, show_log=args['showlog'], filename=logfile)

    with log_setup.applicationbound():
        try:
            log.info('intuition v{} ready'.format(__version__),
                     level=loglevel, bot=args['bot'],
                     context=args['context'],
                     session=args['session'])

            analyzes = intuition(args)
            analyzes.build_report(show=args['showlog'])
        except KeyboardInterrupt:
            log.info('Received SIGINT, cleaning...')
        except Exception as error:
            if loglevel == 'debug':
                raise
            log.error('{}: {}'.format(type(error).__name__, str(error)))
            exit_status = 1

        finally:
            log.info('session ended with status {}'.format(exit_status))

    return exit_status
Ejemplo n.º 2
0
def main():
    # General simulation behavior is defined using command line arguments
    exit_status = 0
    args = setup.parse_commandline()
    loglevel = os.environ.get('LOG', 'warning')
    logfile = setup.logfile(args['session'])
    # Setup structured logs with file and stdout support
    log_setup = dna.logging.setup(level=loglevel,
                                  show_log=args['showlog'],
                                  filename=logfile)

    with log_setup.applicationbound():
        try:
            log.info('intuition v{} ready'.format(__version__),
                     level=loglevel,
                     bot=args['bot'],
                     context=args['context'],
                     session=args['session'])

            analyzes = intuition(args)
            analyzes.build_report(show=args['showlog'])
        except KeyboardInterrupt:
            log.info('Received SIGINT, cleaning...')
        except Exception as error:
            if loglevel == 'debug':
                raise
            log.error('{}: {}'.format(type(error).__name__, str(error)))
            exit_status = 1

        finally:
            log.info('session ended with status {}'.format(exit_status))

    return exit_status
Ejemplo n.º 3
0
 def test_logfile(self):
     logfile = configuration.logfile('fake_id')
     if 'tmp' in logfile:
         self.assertEqual('/tmp/logs/fake_id.log', logfile)
     else:
         self.assertIn('.intuition/logs/fake_id.log', logfile)
Ejemplo n.º 4
0
 def test_logfile(self):
     logfile = configuration.logfile('fake_id')
     if 'tmp' in logfile:
         self.assertEqual('/tmp/logs/fake_id.log', logfile)
     else:
         self.assertIn('.intuition/logs/fake_id.log', logfile)