-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from ubopod/stack
remove current_application and current_menu from MenuWidget and keep everything in \"stack\"
- Loading branch information
Showing
16 changed files
with
602 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "ubo-gui" | ||
version = "0.8.0" | ||
version = "0.9.1" | ||
description = "GUI sdk for Ubo Pod" | ||
authors = ["Sassan Haradji <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# ruff: noqa: D100, D101, D102, D103, D104, D107 | ||
from __future__ import annotations | ||
|
||
import logging | ||
import sys | ||
|
||
logger = logging.getLogger('ubo-gui') | ||
logger.propagate = False | ||
|
||
|
||
class ExtraFormatter(logging.Formatter): | ||
def_keys = ( | ||
'name', | ||
'msg', | ||
'args', | ||
'levelname', | ||
'levelno', | ||
'pathname', | ||
'filename', | ||
'module', | ||
'exc_info', | ||
'exc_text', | ||
'stack_info', | ||
'lineno', | ||
'funcName', | ||
'created', | ||
'msecs', | ||
'relativeCreated', | ||
'thread', | ||
'threadName', | ||
'processName', | ||
'process', | ||
'message', | ||
) | ||
|
||
def format(self: ExtraFormatter, record: logging.LogRecord) -> str: | ||
string = super().format(record) | ||
extra = {k: v for k, v in record.__dict__.items() if k not in self.def_keys} | ||
if len(extra) > 0: | ||
string += ' - extra: ' + str(extra) | ||
|
||
return string | ||
|
||
|
||
def add_stdout_handler(level: int = logging.DEBUG) -> None: | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
stdout_handler.setLevel(level) | ||
stdout_handler.setFormatter( | ||
ExtraFormatter( | ||
'%(created)f [%(levelname)s] %(message)s', | ||
'%Y-%m-%d %H:%M:%S', | ||
), | ||
) | ||
logger.addHandler(stdout_handler) | ||
|
||
|
||
def add_file_handler(level: int = logging.DEBUG) -> None: | ||
file_handler = logging.FileHandler('ubo-gui.log') | ||
file_handler.setLevel(level) | ||
file_handler.setFormatter( | ||
ExtraFormatter( | ||
'%(created)f [%(levelname)s] %(message)s', | ||
'%Y-%m-%d %H:%M:%S', | ||
), | ||
) | ||
logger.addHandler(file_handler) | ||
|
||
|
||
__all__ = ('logger', 'add_stdout_handler', 'add_file_handler') |
Oops, something went wrong.