Модул за водене на регистър на python.

Примерен код

12
0

водене на дневник python файл

import logging
import sys

logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s | %(levelname)s | %(message)s', 
                              '%m-%d-%Y %H:%M:%S')

stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(logging.DEBUG)
stdout_handler.setFormatter(formatter)

file_handler = logging.FileHandler('logs.log')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)

logger.addHandler(file_handler)
logger.addHandler(stdout_handler)
8
0

import logging

logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
  
logger.debug("some debugging...")
logger.error("some error...")
1
0

Logging
In many cases it can be useful to print the
response and/or request details in order to 
help you create the correct expectations and 
send the correct requests. To do help you do thi
s you can use one of the predefined filters 
supplied with REST Assured or you can use one of the shortcuts.

Request Logging

given().log().all(). .. //
Log all request specification details
including parameters, headers and body
given().log().params(). .. // Log only the parameters of the request
given().log().body(). .. // Log only the request body
given().log().headers(). .. // Log only the request headers
given().log().cookies(). .. // Log only the request cookies
given().log().method(). .. // Log only the request method
given().log().path(). .. // Log only the request path
0
0

 I use Log4J for logging. I always log important steps in the test execution. 
 That helps me to debug when there is a
failure.
● Log4J is not a replacement for HTML reports.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j- core</artifactId>
<version>2.11.0</version>
</dependency>
0
0

I use Log4J for logging. 
I always log important steps in the test
execution. That helps me to debug
when there is a failure.
Log4J is not a replacement for HTML reports.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j- core</artifactId>
<version>2.11.0</version>
</dependency>
-1
0

секретарят pythong за сеч в низ

import logging
try:
    from cStringIO import StringIO      # Python 2
except ImportError:
    from io import StringIO

class LevelFilter(logging.Filter):
    def __init__(self, levels):
        self.levels = levels

    def filter(self, record):
        return record.levelno in self.levels

log_stream = StringIO()    
logging.basicConfig(stream=log_stream, level=logging.NOTSET)
logging.getLogger().addFilter(LevelFilter((logging.INFO, logging.WARNING, logging.ERROR)))

logging.info('hello world')
logging.warning('be careful!')
logging.debug("you won't see this")
logging.error('you will see this')
logging.critical('critical is no longer logged!')

print(log_stream.getvalue())

На други езици

Тази страница на други езици

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Íslensk
..................................................................................................................