Module Expr Str Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Str Assign NameStore Str Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore ListLoad Str Str Str Str Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr keyword BinOpMod Str NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword AttributeLoad NameLoad attr keyword BinOpMod Str NameLoad keyword AttributeLoad NameLoad attr keyword Str Expr Call AttributeLoad NameLoad attr Str keyword AttributeLoad NameLoad attr keyword BinOpMod Str NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr keyword BinOpMod Str NameLoad keyword Str Assign NameStore Str Assign NameStore Call AttributeLoad Str attr TupleLoad NameLoad Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Str FunctionDef arguments args NameParam NameParam defaults vararg kwarg body Expr Str If CompareNotIn NameLoad NameLoad body Expr Call NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str BinOpBitOr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body If Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad ListComp IfExp Call NameLoad NameLoad NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr Return NameLoad decorator_list decorator_list Assign NameStore Call NameLoad ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body AugAssignAdd NameStore BinOpAdd Str Call AttributeLoad Str attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str Str Assign NameStore Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad BinOpMult AttributeLoad NameLoad attr Num NameLoad Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad decorator_list decorator_list FunctionDef arguments args defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str If NameLoad body TryExcept body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad name NameStore body Print BinOpMod Str NameLoad If UnaryOpNot NameLoad body Assign NameStore Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list AttributeLoad NameLoad attr
N/A N/A Logging mechanisms for use in OpenHTF.

There are two types of logs within OpenHTF, framework logs, and test logs.
Framework logs are logs that are not included in test record output, while
test logs are.  Framework logs are typically internal to OpenHTF, and are
only interesting when debugging weird framework behavior.

Test logs are primarily generated by test authors, and are included in test
record output.  The preferred way to do this is via the 'test' first parameter
passed to test phases:

  def MyLoggingPhase(test):
    test.logger.info('My log line')

In order to facilitate adding logs to the test record output from places
outside the test phase (without forcing the author to pass the logger object
around), a user can directly use the 'openhtf.test_record' logger.  As a
convenience, this is exposed as a constant in this module, RECORD_LOGGER.
This enables test authors to add log lines to the test record output via:

  import logging
  from openhtf.util import logs

  def MyRandomMethod():
    logging.getLogger(logs.RECORD_LOGGER).info('My log line')

Framework logs are by default output only to stderr at a warning level.  They
can be additionally logged to a file (with a different level) via the
--log-file and --log-file-level flags.  The --quiet flag may be set to suppress
all framework log output to stderr.  The --verbosity flag may be used to set
the log level threshold for framework logs output to stderr.

Test record logs are by default output to stdout at a debug level.  There is
no way to change this, if you don't like it redirect stdout to /dev/null.
 N/A argparse N/A collections N/A functools N/A logging N/A os N/A re N/A sys N/A traceback datetime datetime openhtf util openhtf.util argv openhtf.util functions N/A DEFAULT_LEVEL warning N/A DEFAULT_LOGFILE_LEVEL warning N/A QUIET False N/A LOGFILE None N/A LEVEL_CHOICES N/A debug info warning error critical N/A ARG_PARSER N/A N/A argv ModuleParser N/A N/A N/A ARG_PARSER add_argument --verbosity default DEFAULT_LEVEL choices LEVEL_CHOICES action N/A argv StoreInModule target N/A %s.DEFAULT_LEVEL __name__ help Console log verbosity level (stderr). N/A N/A N/A ARG_PARSER add_argument --quiet action N/A argv StoreInModule target N/A %s.QUIET __name__ proxy N/A argparse _StoreTrueAction help Don't output logs to stderr. N/A N/A N/A ARG_PARSER add_argument --log-file action N/A argv StoreInModule target N/A %s.LOGFILE __name__ help Filename to output logs to, if any. N/A N/A N/A ARG_PARSER add_argument --log-file-level default DEFAULT_LEVEL choices LEVEL_CHOICES action N/A argv StoreInModule target N/A %s.DEFAULT_LOGFILE_LEVEL __name__ help Logging verbosity level for log file output. N/A LOGGER_PREFIX openhtf N/A RECORD_LOGGER N/A N/A . join N/A LOGGER_PREFIX test_record N/A _LOGONCE_SEEN N/A set N/A LogRecord N/A N/A collections namedtuple LogRecord level logger_name source lineno timestamp_millis message LogOnce N/A N/A log_func msg N/A args kwargs N/A N/A "Logs a message only once. N/A N/A msg _LOGONCE_SEEN N/A N/A N/A log_func msg args kwargs N/A N/A N/A _LOGONCE_SEEN add msg N/A MacAddressLogFilter N/A N/A logging Filter N/A N/A A filter which redacts mac addresses if it sees one. N/A MAC_REPLACE_RE N/A N/A re compile 
        ((?:[\dA-F]{2}:){3})       # 3-part prefix, f8:8f:ca means google
        (?:[\dA-F]{2}(:|\b)){3}    # the remaining octets
         N/A N/A re IGNORECASE N/A re VERBOSE N/A MAC_REPLACEMENT \1<REDACTED> __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super MacAddressLogFilter self __init__ N/A filter N/A N/A self record N/A N/A N/A N/A N/A N/A self MAC_REPLACE_RE search N/A N/A record getMessage N/A N/A N/A record msg N/A N/A N/A self MAC_REPLACE_RE sub N/A self MAC_REPLACEMENT N/A record msg N/A N/A record args N/A tuple N/A N/A N/A isinstance arg basestring N/A N/A N/A self MAC_REPLACE_RE sub N/A self MAC_REPLACEMENT N/A str arg arg N/A arg N/A record args N/A True N/A N/A N/A MAC_FILTER N/A MacAddressLogFilter RecordHandler N/A N/A logging Handler N/A N/A A handler to save logs to an HTF TestRecord. __init__ N/A N/A self test_record N/A N/A N/A N/A N/A N/A super RecordHandler self __init__ level N/A logging DEBUG N/A N/A self _test_record test_record N/A N/A N/A self addFilter MAC_FILTER N/A emit N/A N/A self record N/A N/A N/A Save a logging.LogRecord to our test record.

    LogRecords carry a significant amount of information with them including the
    logger name and level information.  This allows us to be a little clever
    about what we store so that filtering can occur on the client.

    Args:
      record: A logging.LogRecord to log.
     N/A message N/A N/A record getMessage N/A N/A record exc_info N/A N/A message N/A N/A N/A join N/A N/A traceback format_exception N/A record exc_info N/A message N/A N/A message decode utf8 replace N/A log_record N/A LogRecord N/A record levelno N/A record name N/A N/A N/A os path basename N/A record pathname N/A record lineno N/A int N/A N/A record created 1000 message N/A N/A N/A N/A N/A self _test_record log_records append log_record N/A N/A SetupLogger N/A N/A N/A N/A N/A Configure logging for OpenHTF. N/A record_logger N/A N/A logging getLogger RECORD_LOGGER N/A N/A record_logger propagate False N/A N/A N/A record_logger setLevel N/A logging DEBUG N/A N/A N/A record_logger addHandler N/A N/A logging StreamHandler stream N/A sys stdout N/A logger N/A N/A logging getLogger LOGGER_PREFIX N/A N/A logger propagate False N/A N/A N/A logger setLevel N/A logging DEBUG N/A formatter N/A N/A logging Formatter %(asctime)s - %(levelname)s - %(message)s N/A LOGFILE N/A N/A N/A N/A cur_time N/A str N/A N/A util TimeMillis N/A file_handler N/A N/A logging FileHandler N/A %s.%s N/A LOGFILE cur_time N/A N/A N/A file_handler setFormatter formatter N/A N/A N/A file_handler setLevel N/A N/A DEFAULT_LOGFILE_LEVEL upper N/A N/A N/A file_handler addFilter MAC_FILTER N/A N/A N/A logger addHandler file_handler N/A N/A N/A IOError N/A exception N/A N/A N/A Failed to set up log file due to error: %s. Continuing anyway. exception N/A N/A QUIET N/A N/A console_handler N/A N/A logging StreamHandler stream N/A sys stderr N/A N/A N/A console_handler setFormatter formatter N/A N/A N/A console_handler setLevel N/A N/A DEFAULT_LEVEL upper N/A N/A N/A console_handler addFilter MAC_FILTER N/A N/A N/A logger addHandler console_handler N/A N/A functions CallOnce