neulab/docprompting-conala huggingface dataset:
class logging.handlers.NTEventLogHandler(appname, dllname=None, logtype='Application')  
Returns a new instance of the NTEventLogHandler class. The appname is used to define the application name as it appears in the event log. An appropriate registry entry is created using this name. The dllname should give the fully qualified pathname of a .dll or .exe which contains message definitions to hold in the log (if not specified, 'win32service.pyd' is used - this is installed with the Win32 extensions and contains some basic placeholder message definitions. Note that use of these placeholders will make your event logs big, as the entire message source is held in the log. If you want slimmer logs, you have to pass in the name of your own .dll or .exe which contains the message definitions you want to use in the event log). The logtype is one of 'Application', 'System' or 'Security', and defaults to 'Application'.  
close()  
At this point, you can remove the application name from the registry as a source of event log entries. However, if you do this, you will not be able to see the events as you intended in the Event Log Viewer - it needs to be able to access the registry to get the .dll name. The current version does not do this. 
  
emit(record)  
Determines the message ID, event category and event type, and then logs the message in the NT event log. 
  
getEventCategory(record)  
Returns the event category for the record. Override this if you want to specify your own categories. This version returns 0. 
  
getEventType(record)  
Returns the event type for the record. Override this if you want to specify your own types. This version does a mapping using the handler’s typemap attribute, which is set up in __init__() to a dictionary which contains mappings for DEBUG, INFO, WARNING, ERROR and CRITICAL. If you are using your own levels, you will either need to override this method or place a suitable dictionary in the handler’s typemap attribute. 
  
getMessageID(record)  
Returns the message ID for the record. If you are using your own messages, you could do this by having the msg passed to the logger being an ID rather than a format string. Then, in here, you could use a dictionary lookup to get the message ID. This version returns 1, which is the base message ID in win32service.pyd.
close()  
At this point, you can remove the application name from the registry as a source of event log entries. However, if you do this, you will not be able to see the events as you intended in the Event Log Viewer - it needs to be able to access the registry to get the .dll name. The current version does not do this.
emit(record)  
Determines the message ID, event category and event type, and then logs the message in the NT event log.
getEventCategory(record)  
Returns the event category for the record. Override this if you want to specify your own categories. This version returns 0.
getEventType(record)  
Returns the event type for the record. Override this if you want to specify your own types. This version does a mapping using the handler’s typemap attribute, which is set up in __init__() to a dictionary which contains mappings for DEBUG, INFO, WARNING, ERROR and CRITICAL. If you are using your own levels, you will either need to override this method or place a suitable dictionary in the handler’s typemap attribute.
getMessageID(record)  
Returns the message ID for the record. If you are using your own messages, you could do this by having the msg passed to the logger being an ID rather than a format string. Then, in here, you could use a dictionary lookup to get the message ID. This version returns 1, which is the base message ID in win32service.pyd.
class logging.handlers.QueueHandler(queue)  
Returns a new instance of the QueueHandler class. The instance is initialized with the queue to send messages to. The queue can be any queue-like object; it’s used as-is by the enqueue() method, which needs to know how to send messages to it. The queue is not required to have the task tracking API, which means that you can use SimpleQueue instances for queue.  
emit(record)  
Enqueues the result of preparing the LogRecord. Should an exception occur (e.g. because a bounded queue has filled up), the handleError() method is called to handle the error. This can result in the record silently being dropped (if logging.raiseExceptions is False) or a message printed to sys.stderr (if logging.raiseExceptions is True). 
  
prepare(record)  
Prepares a record for queuing. The object returned by this method is enqueued. The base implementation formats the record to merge the message, arguments, and exception information, if present. It also removes unpickleable items from the record in-place. You might want to override this method if you want to convert the record to a dict or JSON string, or send a modified copy of the record while leaving the original intact. 
  
enqueue(record)  
Enqueues the record on the queue using put_nowait(); you may want to override this if you want to use blocking behaviour, or a timeout, or a customized queue implementation.
emit(record)  
Enqueues the result of preparing the LogRecord. Should an exception occur (e.g. because a bounded queue has filled up), the handleError() method is called to handle the error. This can result in the record silently being dropped (if logging.raiseExceptions is False) or a message printed to sys.stderr (if logging.raiseExceptions is True).
enqueue(record)  
Enqueues the record on the queue using put_nowait(); you may want to override this if you want to use blocking behaviour, or a timeout, or a customized queue implementation.
prepare(record)  
Prepares a record for queuing. The object returned by this method is enqueued. The base implementation formats the record to merge the message, arguments, and exception information, if present. It also removes unpickleable items from the record in-place. You might want to override this method if you want to convert the record to a dict or JSON string, or send a modified copy of the record while leaving the original intact.
class logging.handlers.QueueListener(queue, *handlers, respect_handler_level=False)  
Returns a new instance of the QueueListener class. The instance is initialized with the queue to send messages to and a list of handlers which will handle entries placed on the queue. The queue can be any queue-like object; it’s passed as-is to the dequeue() method, which needs to know how to get messages from it. The queue is not required to have the task tracking API (though it’s used if available), which means that you can use SimpleQueue instances for queue. If respect_handler_level is True, a handler’s level is respected (compared with the level for the message) when deciding whether to pass messages to that handler; otherwise, the behaviour is as in previous Python versions - to always pass each message to each handler.  Changed in version 3.5: The respect_handler_level argument was added.   
dequeue(block)  
Dequeues a record and return it, optionally blocking. The base implementation uses get(). You may want to override this method if you want to use timeouts or work with custom queue implementations. 
  
prepare(record)  
Prepare a record for handling. This implementation just returns the passed-in record. You may want to override this method if you need to do any custom marshalling or manipulation of the record before passing it to the handlers. 
  
handle(record)  
Handle a record. This just loops through the handlers offering them the record to handle. The actual object passed to the handlers is that which is returned from prepare(). 
  
start()  
Starts the listener. This starts up a background thread to monitor the queue for LogRecords to process. 
  
stop()  
Stops the listener. This asks the thread to terminate, and then waits for it to do so. Note that if you don’t call this before your application exits, there may be some records still left on the queue, which won’t be processed. 
  
enqueue_sentinel()  
Writes a sentinel to the queue to tell the listener to quit. This implementation uses put_nowait(). You may want to override this method if you want to use timeouts or work with custom queue implementations.  New in version 3.3.
dequeue(block)  
Dequeues a record and return it, optionally blocking. The base implementation uses get(). You may want to override this method if you want to use timeouts or work with custom queue implementations.
enqueue_sentinel()  
Writes a sentinel to the queue to tell the listener to quit. This implementation uses put_nowait(). You may want to override this method if you want to use timeouts or work with custom queue implementations.  New in version 3.3.
handle(record)  
Handle a record. This just loops through the handlers offering them the record to handle. The actual object passed to the handlers is that which is returned from prepare().
prepare(record)  
Prepare a record for handling. This implementation just returns the passed-in record. You may want to override this method if you need to do any custom marshalling or manipulation of the record before passing it to the handlers.
start()  
Starts the listener. This starts up a background thread to monitor the queue for LogRecords to process.
stop()  
Stops the listener. This asks the thread to terminate, and then waits for it to do so. Note that if you don’t call this before your application exits, there may be some records still left on the queue, which won’t be processed.
class logging.handlers.RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False, errors=None)  
Returns a new instance of the RotatingFileHandler class. The specified file is opened and used as the stream for logging. If mode is not specified, 'a' is used. If encoding is not None, it is used to open the file with that encoding. If delay is true, then file opening is deferred until the first call to emit(). By default, the file grows indefinitely. If errors is provided, it determines how encoding errors are handled. You can use the maxBytes and backupCount values to allow the file to rollover at a predetermined size. When the size is about to be exceeded, the file is closed and a new file is silently opened for output. Rollover occurs whenever the current log file is nearly maxBytes in length; but if either of maxBytes or backupCount is zero, rollover never occurs, so you generally want to set backupCount to at least 1, and have a non-zero maxBytes. When backupCount is non-zero, the system will save old log files by appending the extensions ‘.1’, ‘.2’ etc., to the filename. For example, with a backupCount of 5 and a base file name of app.log, you would get app.log, app.log.1, app.log.2, up to app.log.5. The file being written to is always app.log. When this file is filled, it is closed and renamed to app.log.1, and if files app.log.1, app.log.2, etc. exist, then they are renamed to app.log.2, app.log.3 etc. respectively.  Changed in version 3.6: As well as string values, Path objects are also accepted for the filename argument.   Changed in version 3.9: The errors parameter was added.   
doRollover()  
Does a rollover, as described above. 
  
emit(record)  
Outputs the record to the file, catering for rollover as described previously.
emit(record)  
Outputs the record to the file, catering for rollover as described previously.
class logging.handlers.SMTPHandler(mailhost, fromaddr, toaddrs, subject, credentials=None, secure=None, timeout=1.0)  
Returns a new instance of the SMTPHandler class. The instance is initialized with the from and to addresses and subject line of the email. The toaddrs should be a list of strings. To specify a non-standard SMTP port, use the (host, port) tuple format for the mailhost argument. If you use a string, the standard SMTP port is used. If your SMTP server requires authentication, you can specify a (username, password) tuple for the credentials argument. To specify the use of a secure protocol (TLS), pass in a tuple to the secure argument. This will only be used when authentication credentials are supplied. The tuple should be either an empty tuple, or a single-value tuple with the name of a keyfile, or a 2-value tuple with the names of the keyfile and certificate file. (This tuple is passed to the smtplib.SMTP.starttls() method.) A timeout can be specified for communication with the SMTP server using the timeout argument.  New in version 3.3: The timeout argument was added.   
emit(record)  
Formats the record and sends it to the specified addressees. 
  
getSubject(record)  
If you want to specify a subject line which is record-dependent, override this method.
getSubject(record)  
If you want to specify a subject line which is record-dependent, override this method.
class logging.handlers.SocketHandler(host, port)  
Returns a new instance of the SocketHandler class intended to communicate with a remote machine whose address is given by host and port.  Changed in version 3.4: If port is specified as None, a Unix domain socket is created using the value in host - otherwise, a TCP socket is created.   
close()  
Closes the socket. 
  
emit()  
Pickles the record’s attribute dictionary and writes it to the socket in binary format. If there is an error with the socket, silently drops the packet. If the connection was previously lost, re-establishes the connection. To unpickle the record at the receiving end into a LogRecord, use the makeLogRecord() function. 
  
handleError()  
Handles an error which has occurred during emit(). The most likely cause is a lost connection. Closes the socket so that we can retry on the next event. 
  
makeSocket()  
This is a factory method which allows subclasses to define the precise type of socket they want. The default implementation creates a TCP socket (socket.SOCK_STREAM). 
  
makePickle(record)  
Pickles the record’s attribute dictionary in binary format with a length prefix, and returns it ready for transmission across the socket. The details of this operation are equivalent to: data = pickle.dumps(record_attr_dict, 1)
datalen = struct.pack('>L', len(data))
return datalen + data
 Note that pickles aren’t completely secure. If you are concerned about security, you may want to override this method to implement a more secure mechanism. For example, you can sign pickles using HMAC and then verify them on the receiving end, or alternatively you can disable unpickling of global objects on the receiving end. 
  
send(packet)  
Send a pickled byte-string packet to the socket. The format of the sent byte-string is as described in the documentation for makePickle(). This function allows for partial sends, which can happen when the network is busy. 
  
createSocket()  
Tries to create a socket; on failure, uses an exponential back-off algorithm. On initial failure, the handler will drop the message it was trying to send. When subsequent messages are handled by the same instance, it will not try connecting until some time has passed. The default parameters are such that the initial delay is one second, and if after that delay the connection still can’t be made, the handler will double the delay each time up to a maximum of 30 seconds. This behaviour is controlled by the following handler attributes:  
retryStart (initial delay, defaulting to 1.0 seconds). 
retryFactor (multiplier, defaulting to 2.0). 
retryMax (maximum delay, defaulting to 30.0 seconds).  This means that if the remote listener starts up after the handler has been used, you could lose messages (since the handler won’t even attempt a connection until the delay has elapsed, but just silently drop messages during the delay period).
createSocket()  
Tries to create a socket; on failure, uses an exponential back-off algorithm. On initial failure, the handler will drop the message it was trying to send. When subsequent messages are handled by the same instance, it will not try connecting until some time has passed. The default parameters are such that the initial delay is one second, and if after that delay the connection still can’t be made, the handler will double the delay each time up to a maximum of 30 seconds. This behaviour is controlled by the following handler attributes:  
retryStart (initial delay, defaulting to 1.0 seconds). 
retryFactor (multiplier, defaulting to 2.0). 
retryMax (maximum delay, defaulting to 30.0 seconds).  This means that if the remote listener starts up after the handler has been used, you could lose messages (since the handler won’t even attempt a connection until the delay has elapsed, but just silently drop messages during the delay period).
emit()  
Pickles the record’s attribute dictionary and writes it to the socket in binary format. If there is an error with the socket, silently drops the packet. If the connection was previously lost, re-establishes the connection. To unpickle the record at the receiving end into a LogRecord, use the makeLogRecord() function.
handleError()  
Handles an error which has occurred during emit(). The most likely cause is a lost connection. Closes the socket so that we can retry on the next event.
makePickle(record)  
Pickles the record’s attribute dictionary in binary format with a length prefix, and returns it ready for transmission across the socket. The details of this operation are equivalent to: data = pickle.dumps(record_attr_dict, 1)
datalen = struct.pack('>L', len(data))
return datalen + data
 Note that pickles aren’t completely secure. If you are concerned about security, you may want to override this method to implement a more secure mechanism. For example, you can sign pickles using HMAC and then verify them on the receiving end, or alternatively you can disable unpickling of global objects on the receiving end.
makeSocket()  
This is a factory method which allows subclasses to define the precise type of socket they want. The default implementation creates a TCP socket (socket.SOCK_STREAM).
send(packet)  
Send a pickled byte-string packet to the socket. The format of the sent byte-string is as described in the documentation for makePickle(). This function allows for partial sends, which can happen when the network is busy.
emit(record)  
The record is formatted, and then sent to the syslog server. If exception information is present, it is not sent to the server.  Changed in version 3.2.1: (See: bpo-12168.) In earlier versions, the message sent to the syslog daemons was always terminated with a NUL byte, because early versions of these daemons expected a NUL terminated message - even though it’s not in the relevant specification (RFC 5424). More recent versions of these daemons don’t expect the NUL byte but strip it off if it’s there, and even more recent daemons (which adhere more closely to RFC 5424) pass the NUL byte on as part of the message. To enable easier handling of syslog messages in the face of all these differing daemon behaviours, the appending of the NUL byte has been made configurable, through the use of a class-level attribute, append_nul. This defaults to True (preserving the existing behaviour) but can be set to False on a SysLogHandler instance in order for that instance to not append the NUL terminator.   Changed in version 3.3: (See: bpo-12419.) In earlier versions, there was no facility for an “ident” or “tag” prefix to identify the source of the message. This can now be specified using a class-level attribute, defaulting to "" to preserve existing behaviour, but which can be overridden on a SysLogHandler instance in order for that instance to prepend the ident to every message handled. Note that the provided ident must be text, not bytes, and is prepended to the message exactly as is.
encodePriority(facility, priority)  
Encodes the facility and priority into an integer. You can pass in strings or integers - if strings are passed, internal mapping dictionaries are used to convert them to integers. The symbolic LOG_ values are defined in SysLogHandler and mirror the values defined in the sys/syslog.h header file. Priorities   
Name (string) Symbolic value   
alert LOG_ALERT  
crit or critical LOG_CRIT  
debug LOG_DEBUG  
emerg or panic LOG_EMERG  
err or error LOG_ERR  
info LOG_INFO  
notice LOG_NOTICE  
warn or warning LOG_WARNING   Facilities   
Name (string) Symbolic value   
auth LOG_AUTH  
authpriv LOG_AUTHPRIV  
cron LOG_CRON  
daemon LOG_DAEMON  
ftp LOG_FTP  
kern LOG_KERN  
lpr LOG_LPR  
mail LOG_MAIL  
news LOG_NEWS  
syslog LOG_SYSLOG  
user LOG_USER  
uucp LOG_UUCP  
local0 LOG_LOCAL0  
local1 LOG_LOCAL1  
local2 LOG_LOCAL2  
local3 LOG_LOCAL3  
local4 LOG_LOCAL4  
local5 LOG_LOCAL5  
local6 LOG_LOCAL6  
local7 LOG_LOCAL7
mapPriority(levelname)  
Maps a logging level name to a syslog priority name. You may need to override this if you are using custom levels, or if the default algorithm is not suitable for your needs. The default algorithm maps DEBUG, INFO, WARNING, ERROR and CRITICAL to the equivalent syslog names, and all other level names to ‘warning’.
emit(record)  
Outputs the record to the file, catering for rollover as described above.
class logging.handlers.WatchedFileHandler(filename, mode='a', encoding=None, delay=False, errors=None)  
Returns a new instance of the WatchedFileHandler class. The specified file is opened and used as the stream for logging. If mode is not specified, 'a' is used. If encoding is not None, it is used to open the file with that encoding. If delay is true, then file opening is deferred until the first call to emit(). By default, the file grows indefinitely. If errors is provided, it determines how encoding errors are handled.  Changed in version 3.6: As well as string values, Path objects are also accepted for the filename argument.   Changed in version 3.9: The errors parameter was added.   
reopenIfNeeded()  
Checks to see if the file has changed. If it has, the existing stream is flushed and closed and the file opened again, typically as a precursor to outputting the record to the file.  New in version 3.6.  
  
emit(record)  
Outputs the record to the file, but first calls reopenIfNeeded() to reopen the file if it has changed.
emit(record)  
Outputs the record to the file, but first calls reopenIfNeeded() to reopen the file if it has changed.
reopenIfNeeded()  
Checks to see if the file has changed. If it has, the existing stream is flushed and closed and the file opened again, typically as a precursor to outputting the record to the file.  New in version 3.6.
logging.info(msg, *args, **kwargs)  
Logs a message with level INFO on the root logger. The arguments are interpreted as for debug().
logging.lastResort  
A “handler of last resort” is available through this attribute. This is a StreamHandler writing to sys.stderr with a level of WARNING, and is used to handle logging events in the absence of any logging configuration. The end result is to just print the message to sys.stderr. This replaces the earlier error message saying that “no handlers could be found for logger XYZ”. If you need the earlier behaviour for some reason, lastResort can be set to None.  New in version 3.2.
logging.log(level, msg, *args, **kwargs)  
Logs a message with level level on the root logger. The other arguments are interpreted as for debug().  Note The above module-level convenience functions, which delegate to the root logger, call basicConfig() to ensure that at least one handler is available. Because of this, they should not be used in threads, in versions of Python earlier than 2.7.1 and 3.2, unless at least one handler has been added to the root logger before the threads are started. In earlier versions of Python, due to a thread safety shortcoming in basicConfig(), this can (under rare circumstances) lead to handlers being added multiple times to the root logger, which can in turn lead to multiple messages for the same event.
addHandler(hdlr)  
Adds the specified handler hdlr to this logger.
critical(msg, *args, **kwargs)  
Logs a message with level CRITICAL on this logger. The arguments are interpreted as for debug().
error(msg, *args, **kwargs)  
Logs a message with level ERROR on this logger. The arguments are interpreted as for debug().
exception(msg, *args, **kwargs)  
Logs a message with level ERROR on this logger. The arguments are interpreted as for debug(). Exception info is added to the logging message. This method should only be called from an exception handler.