B
    EDbÄ  ã               @   sb   d Z ddlZddlZddlZdZdadd„ Zdd	d
„Zddd„Zddd„Z	ddd„Z
ddd„ZdS )a  
Setup the loglevel for services on this particular server.

When the system calles the log function write() it is always associated with a
log-level. Whether or not the log-line reaches all the way to the syslog depends
on the current loglevel configuration.

The main log function is called write(). It logs by default in level 3 if not
overridden with the loglevel keyword argument.

Log-levels::
	Error levels:
	1 = Critical error (unimplemented resolution and undefined consequences)
	2 = Elevated error (high priority error)
	3 = Normal error
	
	Info level:
	4 = Info           (Log brief remarks about successful operations)
	
	Debug levels:
	5 = Notices        (inline log messages for tracing problems)
	6 = Debug          (manual tracing)
	7 = trace          (trace details)
é    Nz*Jakob Simon-Gaarde <jakob@simon-gaarde.dk>é   c             C   s   | a d S )N)Úcur_loglevel)Úlevel© r   ú/G:\easytimepro\master/mysite/ladon\tools\log.pyÚset_loglevel!   s    r   é   Fc       	      C   s¬   t |k r|dkrdS y$tjd }d| }t d| ¡}W n   d}t d¡}Y nX | tj¡ t|jƒdkržtjj	|d	d
d}t 
d¡}| |¡ | |¡ | | ¡ dS )aö  
	Maybe write a message to the syslog. If no loglevel is passed the default level is 3.
	
	Log-levels::
		Error levels:
		1 = Critical error (unimplemented resolution and undefined consequences)
		2 = Elevated error (high priority error)
		3 = Normal error
		
		Info level:
		4 = Info           (Log brief remarks about successful operations)
		
		Debug levels:
		5 = Notices        (inline log messages for tracing problems)
		6 = Debug          (manual tracing)
		7 = Trace          (trace details)
	FNZLADON_REMOTE_HOSTz/tmp/ladon_log.%szladonlogger.%sz/tmp/ladon_logZladonloggerr   i 	= é   )ZmaxBytesZbackupCountz%(asctime)s - %(message)s)r   ÚosÚenvironÚloggingZ	getLoggerZsetLevelÚDEBUGÚlenZhandlersZRotatingFileHandlerZ	FormatterZsetFormatterZ
addHandlerÚdebug)	ÚmsgZloglevelÚcontextÚforceZremote_hostZLOG_FILENAMEÚloggerZhandlerZ	formatterr   r   r   Úwrite%   s     



r   c             C   s   t | d||ƒ dS )z
	Send a brief remark to the syslog upon successful operations. Info will only reach the syslog if the current
	loglevel configuration is set to 4 or more.
	r   N)r   )r   r   r   r   r   r   ÚinfoR   s    r   c             C   s   t | d||ƒ dS )z
	Send a notice to the syslog. Notices will only reach the syslog if the current
	loglevel configuration is set to 5 or more.
	r	   N)r   )r   r   r   r   r   r   ÚnoticeZ   s    r   c             C   s   t | d||ƒ dS )z
	Send a debug message to the syslog. Debug messages will only reach the syslog if the current
	loglevel configuration is set to 6 or more.
	é   N)r   )r   r   r   r   r   r   r   a   s    r   c             C   s   t | d||ƒ dS )z
	Send a debug message to the syslog. Debug messages will only reach the syslog if the current
	loglevel configuration is set to 6 or more.
	é   N)r   )r   r   r   r   r   r   Útraceh   s    r   )r   NF)NF)NF)NF)NF)Ú__doc__r
   r   Zlogging.handlersÚ
__author__r   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   
-


