testbot.result.logger

Module Contents

Classes

PackageFilter

Filter instances are used to perform arbitrary filtering of LogRecords.

LoggerManager

日志管理器,可注册多个日志对象,支持模块日志和用例日志分离。

Functions

_zip_directory(dirpath, output_file)

将目标文件夹压缩成zip包并且输出到output_file

_check_and_create_directory(filename)

Attributes

__copyright__

__author__

__email__

logger_level

logger_manager

testbot.result.logger.__author__ = 'Nuanguang Gu(Sunny)'[source]
testbot.result.logger.__email__ = 'nuanguang.gu@aliyun.com'[source]
testbot.result.logger.logger_level[source]
testbot.result.logger._zip_directory(dirpath, output_file)[source]

将目标文件夹压缩成zip包并且输出到output_file 并且将文件删除

testbot.result.logger._check_and_create_directory(filename)[source]
class testbot.result.logger.PackageFilter[source]

Bases: logging.Filter

Filter instances are used to perform arbitrary filtering of LogRecords.

Loggers and Handlers can optionally use Filter instances to filter records as desired. The base filter class only allows events which are below a certain point in the logger hierarchy. For example, a filter initialized with “A.B” will allow events logged by loggers “A.B”, “A.B.C”, “A.B.C.D”, “A.B.D” etc. but not “A.BB”, “B.A.B” etc. If initialized with the empty string, all events are passed.

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class testbot.result.logger.LoggerManager[source]

Bases: object

日志管理器,可注册多个日志对象,支持模块日志和用例日志分离。

register(logger_name: str, filename: str = None, console: bool = True, default_level: str = logging.INFO, **kwargs) logging.Logger[source]

注册logger。 for_test参数默认False,开启则支持模块日志;is_test参数默认False,开启则支持用例日志。

Parameters:
  • logger_name (str) – 日志名称

  • filename (str) – 文件名称

  • console (bool) – 是否控制台输出

  • default_level (str) – 默认日志级别

  • kwargs

Returns:

创建或已注册的日志Logger对象

Return type:

logging.Logger

unregister(logger_name: str)[source]

删除注册的logger,同时将需要打包的logger文件打包

Parameters:

logger_name (str) – 日志名称

Returns:

Return type:

_achieve_files(logger_name)[source]
get_logger(logger_name: str) logging.Logger[source]

获取日志对象 :param logger_name: 日志名称 :type logger_name: str :return: 日志对象 :rtype: logging.Logger

testbot.result.logger.logger_manager[source]