MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / initlog

Function initlog

tools/python-3.11.9-amd64/Lib/cgi.py:65–100  ·  view source on GitHub ↗

Write a log message, if there is a log file. Even though this function is called initlog(), you should always use log(); log is a variable that is set either to initlog (initially), to dolog (once the log file has been opened), or to nolog (when logging is disabled). The

(*allargs)

Source from the content-addressed store, hash-verified

63logfp = None # File object to log to, if not None
64
65def initlog(*allargs):
66 """Write a log message, if there is a log file.
67
68 Even though this function is called initlog(), you should always
69 use log(); log is a variable that is set either to initlog
70 (initially), to dolog (once the log file has been opened), or to
71 nolog (when logging is disabled).
72
73 The first argument is a format string; the remaining arguments (if
74 any) are arguments to the % operator, so e.g.
75 log("%s: %s", "a", "b")
76 will write "a: b" to the log file, followed by a newline.
77
78 If the global logfp is not None, it should be a file object to
79 which log data is written.
80
81 If the global logfp is None, the global logfile may be a string
82 giving a filename to open, in append mode. This file should be
83 world writable!!! If the file can't be opened, logging is
84 silently disabled (since there is no safe place where we could
85 send an error message).
86
87 """
88 global log, logfile, logfp
89 warnings.warn("cgi.log() is deprecated as of 3.10. Use logging instead",
90 DeprecationWarning, stacklevel=2)
91 if logfile and not logfp:
92 try:
93 logfp = open(logfile, "a", encoding="locale")
94 except OSError:
95 pass
96 if not logfp:
97 log = nolog
98 else:
99 log = dolog
100 log(*allargs)
101
102def dolog(fmt, *args):
103 """Write a log message to the log file. See initlog() for docs."""

Callers

nothing calls this directly

Calls 3

logFunction · 0.85
openFunction · 0.70
warnMethod · 0.45

Tested by

no test coverage detected