Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 048840c

Browse files
committed
style consistency:
- always include a space after the "#" that starts a comment - easier to read imports
1 parent 006483b commit 048840c

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

Doc/lib/liblogging.tex

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -527,27 +527,27 @@ \subsection{Logging to multiple destinations \label{multiple-destinations}}
527527
\begin{verbatim}
528528
import logging
529529
530-
#set up logging to file - see previous section for more details
530+
# set up logging to file - see previous section for more details
531531
logging.basicConfig(level=logging.DEBUG,
532532
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
533533
datefmt='%m-%d %H:%M',
534534
filename='/temp/myapp.log',
535535
filemode='w')
536-
#define a Handler which writes INFO messages or higher to the sys.stderr
536+
# define a Handler which writes INFO messages or higher to the sys.stderr
537537
console = logging.StreamHandler()
538538
console.setLevel(logging.INFO)
539-
#set a format which is simpler for console use
539+
# set a format which is simpler for console use
540540
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
541-
#tell the handler to use this format
541+
# tell the handler to use this format
542542
console.setFormatter(formatter)
543-
#add the handler to the root logger
543+
# add the handler to the root logger
544544
logging.getLogger('').addHandler(console)
545545
546-
#Now, we can log to the root logger, or any other logger. First the root...
546+
# Now, we can log to the root logger, or any other logger. First the root...
547547
logging.info('Jackdaws love my big sphinx of quartz.')
548548
549-
#Now, define a couple of other loggers which might represent areas in your
550-
#application:
549+
# Now, define a couple of other loggers which might represent areas in your
550+
# application:
551551
552552
logger1 = logging.getLogger('myapp.area1')
553553
logger2 = logging.getLogger('myapp.area2')
@@ -601,11 +601,11 @@ \subsection{Sending and receiving logging events across a network
601601
# an unformatted pickle
602602
rootLogger.addHandler(socketHandler)
603603
604-
#Now, we can log to the root logger, or any other logger. First the root...
604+
# Now, we can log to the root logger, or any other logger. First the root...
605605
logging.info('Jackdaws love my big sphinx of quartz.')
606606
607-
#Now, define a couple of other loggers which might represent areas in your
608-
#application:
607+
# Now, define a couple of other loggers which might represent areas in your
608+
# application:
609609
610610
logger1 = logging.getLogger('myapp.area1')
611611
logger2 = logging.getLogger('myapp.area2')
@@ -620,14 +620,18 @@ \subsection{Sending and receiving logging events across a network
620620
\module{SocketServer} module. Here is a basic working example:
621621

622622
\begin{verbatim}
623-
import struct, cPickle, logging, logging.handlers
623+
import cPickle
624+
import logging
625+
import logging.handlers
626+
import SocketServer
627+
import struct
624628
625-
from SocketServer import ThreadingTCPServer, StreamRequestHandler
626629
627-
class LogRecordStreamHandler(StreamRequestHandler):
628-
"""
629-
Handler for a streaming logging request. It basically logs the record
630-
using whatever logging policy is configured locally.
630+
class LogRecordStreamHandler(SocketServer.StreamRequestHandler):
631+
"""Handler for a streaming logging request.
632+
633+
This basically logs the record using whatever logging policy is
634+
configured locally.
631635
"""
632636
633637
def handle(self):
@@ -652,31 +656,29 @@ \subsection{Sending and receiving logging events across a network
652656
return cPickle.loads(data)
653657
654658
def handleLogRecord(self, record):
655-
#if a name is specified, we use the named logger rather than the one
656-
#implied by the record.
659+
# if a name is specified, we use the named logger rather than the one
660+
# implied by the record.
657661
if self.server.logname is not None:
658662
name = self.server.logname
659663
else:
660664
name = record.name
661665
logger = logging.getLogger(name)
662-
#N.B. EVERY record gets logged. This is because Logger.handle
663-
#is normally called AFTER logger-level filtering. If you want
664-
#to do filtering, do it at the client end to save wasting
665-
#cycles and network bandwidth!
666+
# N.B. EVERY record gets logged. This is because Logger.handle
667+
# is normally called AFTER logger-level filtering. If you want
668+
# to do filtering, do it at the client end to save wasting
669+
# cycles and network bandwidth!
666670
logger.handle(record)
667671
668-
class LogRecordSocketReceiver(ThreadingTCPServer):
669-
"""
670-
A simple-minded TCP socket-based logging receiver suitable for test
671-
purposes.
672+
class LogRecordSocketReceiver(SocketServer.ThreadingTCPServer):
673+
"""simple TCP socket-based logging receiver suitable for testing.
672674
"""
673675
674676
allow_reuse_address = 1
675677
676678
def __init__(self, host='localhost',
677-
port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
678-
handler=LogRecordStreamHandler):
679-
ThreadingTCPServer.__init__(self, (host, port), handler)
679+
port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
680+
handler=LogRecordStreamHandler):
681+
SocketServer.ThreadingTCPServer.__init__(self, (host, port), handler)
680682
self.abort = 0
681683
self.timeout = 1
682684
self.logname = None

0 commit comments

Comments
 (0)