python learning day24

A, logging module

1.1 log output locations:

  • terminal
  • File # is not specified, the default print-to-end (in this way can only be provided in the form. If you want to output to a file can not be printed to the terminal. There are limitations)

1.2 log format:

  •   % (Asctime) of the current time string s. The default format is "2003-07-0816: 49: 45,896." Milliseconds after the comma
  •   % (Name) s Logger name, not specified defaults to root
  •   % (Levelname) s in text form log level (debug debug, info message, warning warning, error error, critical danger)
  •   % (module) s call log output function module name message #% (message) s output

1.3  Time Format

  • Here specified time format is used to replace the time format of the above asctime

1.4 log level

The relationship between the number corresponding level: default warning level, the level is the corresponding number is 30. By a level-controlled output, output only 30 levels 30, 40, 50 and level of content results.

10 --> debug

20 -> information

30 --> warning

40 --> error

50 --> critical

Note: root is the default log name is not specified, the default is the root.

 

II. Log configuration dictionary

# 1 , the log defines three output formats, format string may be used as the log
 "" "
 % (name) S Logger name, there is no default is the root
 % (levelno) S log level in digital form ( 10 , 20 , 30 , 40 , 50 )
 % (levelname) S text log level (debug debug, info message, warning warning, error error, critical danger)
 % (pathname) S invoke the full path name of the module log output function, may not
 % filename (filename) s calling module log output function of
 % (Module1) S invoking module name of the log output function
 % (funcName) S calls the function name of the log output function
 % (lineno) D call log output function line statement where
 % (Created) F the current time, represented by a standard floating point representation UNIX time
% , The number of milliseconds since the time of creating Logger (relativeCreated) d output log information
 % (asctime) s current time string. The default format is " 2003 - 07 - 08  16 : 49 : 45 , 896 ." Milliseconds after the comma
 % (Thread) D thread ID. It may not have
 % (threadName) S thread name. May not have
 % d process ID (process). May not
 % (Message) message user output S
 "" " 
Output Format 2. Define log: when stressed !! specified therein% (name) s after logging module calls using logging.getLogger () log name

 

Third, use the logging module

1. 
the logging is a package, which requires the use of at config, the getLogger
2.
Import logging.config # logging.getLogger are introduced together with this together, and then the prefix logging.config Import Settings
3.
. 3,
load the configuration dictionary logging.config .dictConfig (settings.LOGGING_DIC)
4, output log
logger1 = logging.getLogger ( 'user transaction')
logger1.info ( 'Egon son alex transfer 300 million Mingbi')

 

Four, re

What is a regular: Regular is to use a bunch of special symbols to express a special law. This special symbols to get one kind of large string to match, according to such a specific rule to take your values.

Regular match

Guess you like

Origin www.cnblogs.com/zhangjiahao996/p/12617131.html