Exemple #1
0
def myMain():
  x=input('Enter x:')

  if argv[1] == 'zen':
    log.level('info')
    log.d('debug')
    log.i('info x={}'.format(x))
    log.w('warn')
    log.e('error')
    log.c('critical')
  else:
    if argv[1] == 'basic':
    # see Python Docs logging.html 16.6.7. LogRecord attributes
      logging.basicConfig(style='{',format="{asctime:s}:{filename:s}:{lineno:d}:{msg:s}",level='DEBUG')
      logging.debug('our debug message x={}'.format(x))
      logging.warn('our warn message x={}'.format(x))

    else:
      print("If we don't want to type logging.debug() etc, we have to create our own logger lg=logging.getLogger({})".format(__name__))
      lg=logging.getLogger(__name__)

      if argv[1]=='easy':
        logging.basicConfig(level='INFO')
      else:
        lg.setLevel('WARN') # optional: defaults to all levels
        lg.addHandler(logging.StreamHandler())
        lg.handlers[0].setFormatter(logging.Formatter(style='{',fmt="{filename:s}:{funcName:s}():{lineno:d}:{msg:s}"))

      lg.debug('our debug mesage')
      lg.info('our info here')
def test_output():
    # All of these just need to output without errors.
    from zenlog import log
    log.debug("A quirky message only developers care about")
    log.info("Curious users might want to know this")
    log.warn("Something is wrong and any user should be informed")
    log.warning("Something is wrong and any user should be informed")
    log.error("Serious stuff, this is red for a reason")
    log.critical("OH NO everything is on fire")
    log.c("OH NO everything is on fire")
    log.crit("OH NO everything is on fire")
Exemple #3
0
def test_output():
    # All of these just need to output without errors.
    from zenlog import log
    log.debug("A quirky message only developers care about")
    log.info("Curious users might want to know this")
    log.warn("Something is wrong and any user should be informed")
    log.warning("Something is wrong and any user should be informed")
    log.error("Serious stuff, this is red for a reason")
    log.critical("OH NO everything is on fire")
    log.c("OH NO everything is on fire")
    log.crit("OH NO everything is on fire")
Exemple #4
0
        log.level(logging.INFO)
    else:
        log.level(logging.DEBUG)

    if args.user_name:
        download_directory = os.path.expanduser(args.directory + '/' +
                                                args.user_name)
    elif args.gallery:
        download_directory = os.path.expanduser(args.directory + '/gallery/' +
                                                args.gallery)

    # make sure the download directory exists, then change to it
    if not os.path.exists(download_directory):
        os.makedirs(download_directory)
    os.chdir(download_directory)

    if args.user_name:
        action_download_submitted_images()
    elif args.gallery:
        action_download_imgur_gallery()


if __name__ == '__main__':
    try:
        main()
    except SystemExit:
        pass
    except:
        log.c('Uncaught Exception:')
        log.c(format_exc())
Exemple #5
0
        log.level(logging.INFO)
    else:
        log.level(logging.DEBUG)

    if args.user_name:
        download_directory = os.path.expanduser(args.directory +
                                                '/' + args.user_name)
    elif args.gallery:
        download_directory = os.path.expanduser(args.directory +
                                                '/gallery/' + args.gallery)

    # make sure the download directory exists, then change to it
    if not os.path.exists(download_directory):
        os.makedirs(download_directory)
    os.chdir(download_directory)

    if args.user_name:
        action_download_submitted_images()
    elif args.gallery:
        action_download_imgur_gallery()


if __name__ == '__main__':
    try:
        main()
    except SystemExit:
        pass
    except:
        log.c('Uncaught Exception:')
        log.c(format_exc())