-
Notifications
You must be signed in to change notification settings - Fork 0
дз #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sdvuuv
wants to merge
1
commit into
main
Choose a base branch
from
finally_last_homework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
дз #16
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,65 @@ | ||
| from Src.Logics.Services.service import service | ||
| from Src.Models.event_type import event_type | ||
| from Src.Storage.storage import storage | ||
| from Src.errors import error_proxy | ||
| from Src.exceptions import exception_proxy | ||
| from Src.Logics.convert_factory import convert_factory | ||
| from Src.Logics.storage_observer import storage_observer | ||
|
|
||
| import os | ||
| import json | ||
| from datetime import datetime | ||
|
|
||
| # | ||
| # Сервис логирования | ||
| # | ||
| class console_log_service(service): | ||
|
|
||
| __storage: storage = None | ||
| __item:error_proxy = None | ||
|
|
||
| def __init__(self, data: list = None) -> None: | ||
| super().__init__(data) | ||
| self.__storage = storage() | ||
| self.__data = [] | ||
| storage_observer.append(self) | ||
|
|
||
| @property | ||
| def item(self) -> error_proxy: | ||
| return self.__item | ||
|
|
||
| @item.setter | ||
| def item(self, value: error_proxy): | ||
| exception_proxy.validate(value, error_proxy) | ||
| self.__item = value | ||
|
|
||
| def __observe_print_log(self): | ||
| """ | ||
| Вывести лог в консоль | ||
| """ | ||
| data = self.__data | ||
| period = datetime.now().strftime('%Y-%m-%d') | ||
| factory = convert_factory() | ||
| data = factory.serialize( data ) | ||
| json_text = json.dumps(data, sort_keys = True, indent = 4, ensure_ascii = False) | ||
| print(f"{period}: {json_text}") | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| def handle_event(self, handle_type: str ): | ||
| """ | ||
| Обработать событие | ||
| Args: | ||
| handle_type (str): Ключ | ||
| """ | ||
| super().handle_event(handle_type) | ||
|
|
||
| # Добавить запись в лог | ||
| if handle_type == event_type.write_log() and self.__item is not None: | ||
| self.__data.append(self.__item) | ||
|
|
||
| # Вывести лог в консоль | ||
| if handle_type == event_type.save_log(): | ||
| self.__observe_print_log() |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -137,11 +137,15 @@ def write_log(message: str, log_type:str = "INFO" ): | |
| Сформировать сообщение для записи лога | ||
| """ | ||
| observer_item = storage_observer.get( storage_observer .log_service_key() ) | ||
| observer_item_console = storage_observer.get( storage_observer .console_log_service_key() ) | ||
|
|
||
| if observer_item is not None: | ||
| item = error_proxy() | ||
| item.error = message | ||
| item.log_type = log_type | ||
|
|
||
| observer_item.item = item | ||
| if observer_item_console is not None: | ||
| observer_item_console.item = item | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Да. Верно. |
||
| storage_observer.raise_event( "write_log" ) | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут не корректно.
console_log_serviceу Вас класс ,а не переменна. Тогда уж:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здравствуйте, с докером все получилось, мы с Кириллом Попвым на моем компьютере на убунту разобрались со всем.





