
    7j                    v    d Z ddlmZ ddlZddlZddlmZ ddlmZ dZ	da
dej                  fddZdd	Zdd
Zy)zStructured logging for the agent.

Logs go to both stdout (useful in CLI mode) and the rotating agent log file.
A redact() helper masks token-like values; callers must NEVER pass raw secrets
to the logger. See SECURITY rules in the README.
    )annotationsN)RotatingFileHandler)Pathz0%(asctime)s %(levelname)-7s %(name)s %(message)sFc                   t         ryt        j                  d      }|j                  |       t        j                  t
              }t        j                  t        j                        }|j                  |       |j                  |       | R	 | j                  j                  dd       t        | ddd      }|j                  |       |j                  |       da yda y# t        $ r}|j                  d	| |       Y d}~da yd}~ww xY w)
z9Configure root logging once. Safe to call multiple times.N	wolfpanelT)parentsexist_oki  P    zutf-8)maxBytesbackupCountencodingzfile logging disabled (%s): %s)_configuredlogging	getLoggersetLevel	Formatter_LOG_FORMATStreamHandlersysstdoutsetFormatter
addHandlerparentmkdirr   OSErrorwarning)log_filelevelroot	formatterstreamfile_handlerexcs          @/var/www/downloads.wolfpanel.net/public_html/agent/src/logger.pysetup_loggingr%      s     [)DMM%!!+.I""3::.F
	"OOF 	JOO!!$!>.?GL %%i0OOL) K$K  	JLL98SIIK	Js   AC# #	D,DDc                2    t        j                  d|        S )z6Return a namespaced logger under the 'wolfpanel' root.z
wolfpanel.)r   r   )names    r$   
get_loggerr(   1   s    z$011    c                @    | syt        |       dk  ry| dd  d| dd  S )zBMask a secret for safe display in logs (never log the full value).z<none>   z****N   z...)len)secrets    r$   redactr0   6   s4    
6{aRaj\VBC[M**r)   )r   zPath | Noner   intreturnNone)r'   strr2   zlogging.Logger)r/   z
str | Noner2   r4   )__doc__
__future__r   r   r   logging.handlersr   pathlibr   r   r   INFOr%   r(   r0    r)   r$   <module>r;      s?    #  
 0 @ +/W\\ <2
+r)   