Format msg for output This is used instead of process() since process() applies to _all_ messages, including debug calls
(self, msg, *args, **kwargs)
| 109 | logging.getLogger("pypsrp").setLevel(logging.ERROR) |
| 110 | |
| 111 | def format(self, msg, *args, **kwargs): |
| 112 | """Format msg for output |
| 113 | |
| 114 | This is used instead of process() since process() applies to _all_ messages, including debug calls |
| 115 | """ |
| 116 | if self.extra is None: |
| 117 | return f"{msg}", kwargs |
| 118 | |
| 119 | if "module_name" in self.extra and len(self.extra["module_name"]) > 11: |
| 120 | self.extra["module_name"] = self.extra["module_name"][:8] + "..." |
| 121 | |
| 122 | # If the logger is being called when hooking the 'options' module function |
| 123 | if len(self.extra) == 1 and ("module_name" in self.extra): |
| 124 | return (f"{colored(self.extra['module_name'], 'cyan', attrs=['bold']):<64} {msg}", kwargs) |
| 125 | |
| 126 | # If the logger is being called from a protocol |
| 127 | module_name = colored(self.extra["module_name"], "cyan", attrs=["bold"]) if "module_name" in self.extra else colored(self.extra["protocol"], "blue", attrs=["bold"]) |
| 128 | |
| 129 | return (f"{module_name:<24} {self.extra['host']:<15} {self.extra['port']:<6} {self.extra['hostname'] if self.extra['hostname'] else 'NONE':<16} {msg}", kwargs) |
| 130 | |
| 131 | @no_debug |
| 132 | def display(self, msg, *args, **kwargs): |
no outgoing calls
no test coverage detected