Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/uaclient/ |
Upload File : |
import json import logging from collections import OrderedDict from typing import Any, Dict # noqa: F401 from uaclient import util class RedactionFilter(logging.Filter): """A logging filter to redact confidential info""" def filter(self, record: logging.LogRecord): record.msg = util.redact_sensitive_logs(str(record.msg)) return True class JsonArrayFormatter(logging.Formatter): """Json Array Formatter for our logging mechanism Custom made for Pro logging needs """ default_time_format = "%Y-%m-%dT%H:%M:%S" default_msec_format = "%s.%03d" required_fields = ( "asctime", "levelname", "name", "funcName", "lineno", "message", ) def format(self, record: logging.LogRecord) -> str: record.message = record.getMessage() record.asctime = self.formatTime(record) extra_message_dict = {} # type: Dict[str, Any] if record.exc_info: extra_message_dict["exc_info"] = self.formatException( record.exc_info ) if not extra_message_dict.get("exc_info") and record.exc_text: extra_message_dict["exc_info"] = record.exc_text if record.stack_info: extra_message_dict["stack_info"] = self.formatStack( record.stack_info ) extra = record.__dict__.get("extra") if extra and isinstance(extra, dict): extra_message_dict.update(extra) # is ordered to maintain order of fields in log output local_log_record = OrderedDict() # type: Dict[str, Any] # update the required fields in the order stated for field in self.required_fields: value = record.__dict__.get(field) local_log_record[field] = value local_log_record["extra"] = extra_message_dict return json.dumps(list(local_log_record.values()))