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_append_logger(filename):
  """
  Get a append logger based on configuration options.

  Parameters
  ----------
  filename : string
    File to log to.
  """
  if not filename:
    return NullLogger()
  print "Append logging at %s." % filename
  return JSONLogger(filename, "a")
Beispiel #3
0
def get_logger(use_log=False, filename=LOG_FILENAME):
  """
  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()
  print "Logging at %s." % filename
  return JSONLogger(filename)
Beispiel #4
0
def get_append_logger(filename, tags):
    """
    Get a append logger based on configuration options.

    Parameters
    ----------
    filename : string
      File to log to.
    tags : string
      Tags to log out
    """
    if not filename:
        return NullLogger()
    print("Append logging at %s" % filename)
    infile = open(filename, 'a')
    return JSONLogger(infile, tags)
Beispiel #5
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()
  if os.path.isdir(filename):
    filename = os.path.normpath(os.path.join(filename, logfilename()))
  print "Starting JSON logging at %s" % filename
  return JSONLogger(filename)
Beispiel #6
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 #7
0
def get_logger():
    return NullLogger()