Current File : //lib/python2.7/site-packages/vdo/utils/Logger.pyo
�
.�t_c@s`dZddlZddlZddlZddlZddlmZdefd��YZdS(si
  Logger - VDO manager logging

  $Id: //eng/vdo-releases/magnesium/src/python/vdo/utils/Logger.py#3 $

i����N(t
MethodTypetLoggercBs~eZdZejjejd�Ze	Z
dZe
d��Ze
de	d��Ze
d��Ze
d��Zd�ZRS(s�Wrappers and configuration methods for the Python logger.

  Attributes:
    logfile (string): the path to the logfile if specified.
    myname (string):  name of the command being run.
    quiet (bool):     if True, don't print to stdout.
  icCs"|js|GHn|j|�dS(s4Print a status message to stdout and log it as well.N(tquiettinfo(tclstloggertmsg((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pytannounce/s	cCs;||_||_|}d}|r*dnd|}tj�}|jtj�tjtj�}|j	tj
|j|��|j|r�tjntj�|j
|�|jdk	r�y�tjj|j�rtjj|j�rt|jd�}	tjd|	�}n!tjj|jddd	d
�}tj
d|�}
|j	|
�|j|retjntj�|j
|�Wq�tk
r�}|jdjd
|jd|��q�XnyStjjdd�}|j	tj
|j|��|jtj�|j
|�Wn)tk
r6}|jdj|��nXdS(s8Configure the logging system according to the arguments.s: %(levelname)s - %(message)ss
: %(name)sttwtstreamtmaxBytesi
itbackupCountis%(asctime)s %(name)ss.Unable to configure logging to {logfile}: {ex}tlogfiletextaddresss/dev/logs,Unable to configure logging for rsyslog: {0}Ni(i�(tmynameR
tloggingt	getLoggertsetLeveltNOTSETt
StreamHandlertsyststderrtsetFormattert	FormattertDEBUGtWARNINGt
addHandlertNonetostpathtexiststisfiletopenthandlerstRotatingFileHandlertINFOt	Exceptiontwarntformatt
SysLogHandler(RtnameR
tdebugt	debuggingt
formatBaset	debugBaseRthandlert	logstreamt	formatterR((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pyt	configure7sB		
+	
cCs.tj|�}t|j||j�|_|S(s;Returns a Python logger decorated with the announce method.(RRRRt	__class__(RR*R((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pyRbscCs6g}|jdk	r2|jdt|j��n|S(sBReturn a list of strings containing the logging options specified.s
--logfile=N(R
Rtappendtstr(Rtoptions((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pytloggingOptionsjscCstt|�j�dS(N(tsuperRt__init__(tself((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pyR9usN(t__name__t
__module__t__doc__RRtbasenameRtargvRtFalseRRR
tclassmethodRR2RR7R9(((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pyR s*(	R=Rtlogging.handlersRRttypesRtobjectR(((s4/usr/lib/python2.7/site-packages/vdo/utils/Logger.pyt<module>s