nerdexam
Python_Institute

PCPP-32-101 · Question #88

Select a log that matches the following format: '%(name)s[%(levelname)s][%(asctime)s]:%(message)s'

The correct answer is C. root[CRITICAL][2019-10-19 18:21:35,407]:Invalid argument. The format '%(name)s[%(levelname)s][%(asctime)s]:%(message)s' matches a log with the logger name, level in brackets, timestamp in brackets (including milliseconds), then a colon and the message. Option C fits this exactly.

PEP and Best Practices

Question

Select a log that matches the following format:

'%(name)s[%(levelname)s][%(asctime)s]:%(message)s'

Options

  • Aroot[CRITICAL][2019-10-19 18:21:35]:Invalid argument
  • Broot:CRITICAL:2019-10-19 18:21:35:Invalid argument
  • Croot[CRITICAL][2019-10-19 18:21:35,407]:Invalid argument
  • Droot:CRITICAL:2019-10-19 18:21:35,407:Invalid argument

How the community answered

(17 responses)
  • A
    12% (2)
  • C
    82% (14)
  • D
    6% (1)

Explanation

The format '%(name)s[%(levelname)s][%(asctime)s]:%(message)s' matches a log with the logger name, level in brackets, timestamp in brackets (including milliseconds), then a colon and the message. Option C fits this exactly.

Topics

#logging#log format string#asctime#levelname

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice