Beispiel #1
0
def get_logger(use_log=False,
               filename=logfilename(),
               expand_json=False,
               sort_keys=False):
    """
    Get a logger based on configuration options.

    Parameters
    ----------
    use_log : bool
      Whether to log or not.
    filename : string
      File to log to.
    """
    if not use_log:
        return NullLogger()
    dirname = os.path.dirname(filename)
    if dirname:
        mkdir_p(dirname)
    print("Starting JSON logging at %s" % filename)
    infile = open(filename, 'w')
    if expand_json:
        logger = JSONLogger
    else:
        logger = JSONBinLogger
    return logger(infile, sort_keys=sort_keys)
Beispiel #2
0
def get_logger(use_log=False, filename=logfilename()):
    """
    Get a logger based on configuration options.

    Parameters
    ----------
    use_log : bool
      Whether to log or not.
    filename : string
      File to log to.
    """
    if not use_log:
        return NullLogger()
    dirname = os.path.dirname(filename)
    if dirname:
        mkdir_p(dirname)
    print("Starting JSON logging at %s" % filename)
    infile = open(filename, 'w')
    return JSONLogger(infile)
Beispiel #3
0
def get_logger(use_log=False, filename=logfilename()):
    """
    Get a logger based on configuration options.

    Parameters
    ----------
    use_log : bool
      Whether to log or not.
    filename : string
      File to log to.
    """
    if not use_log:
        return NullLogger()
    dirname = os.path.dirname(filename)
    if dirname:
        mkdir_p(dirname)
    print("Starting JSON logging at %s" % filename)
    infile = open(filename, 'w')
    return JSONLogger(infile)
Beispiel #4
0
def get_logger(use_log=False, filename=logfilename(), expand_json=False, sort_keys=False):
    """
    Get a logger based on configuration options.

    Parameters
    ----------
    use_log : bool
      Whether to log or not.
    filename : string
      File to log to.
    """
    if not use_log:
        return NullLogger()
    dirname = os.path.dirname(filename)
    if dirname:
        mkdir_p(dirname)
    print("Starting JSON logging at %s" % filename)
    infile = open(filename, 'w')
    if expand_json:
        logger = JSONLogger
    else:
        logger = JSONBinLogger
    return logger(infile, sort_keys=sort_keys)