Skip to content
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

Hw_data_Dudnik #78

Open
wants to merge 3 commits into
base: after_lession
Choose a base branch
from

Conversation

Dudnik-Denys
Copy link
Contributor

Домашнє завдання з теми Дата і час
Змінено три файли, це тому що додав до гіт ігнору лог і hblog (файл який і треба було оброблювати), а також в логері змінив назву файлу в який треба логувати помилки, до того ж я полічив кількість помилок які логуємо (просто для себе). Я написав розгорнутий коментар до дій що робив і чому так робив.

# Після того як ми прочитали потрібні нам дані і зберегли їх - порахуємо різницю наступного і початкового рядку
# (виключаючи останній рядок, щоб не вийти за межі списку, адже його різниця з минулим і так порахується)
# і те чи виходять вони за певні межі часу і в залежності від цього будем логувати варнінг чи ерор.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

загальний недолік вашого підходу - робота зі строкою методами строки, хоч це і звучить парадоксально, але рядок у лозі - явний дікт, тому json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, теж писав за це у коментарі, я можу ковертнути у словник і зробити у вигляді json але це буде ще один цикл, тобто буде більш вимогливим ніж це рішення, але я розумію про що Ви, у вигляді json теж здається мені більш загальним методом.

start = datetime.datetime.strptime(content[i][1], '%H:%M:%S')
end = datetime.datetime.strptime(content[i + 1][1], '%H:%M:%S')
if datetime.timedelta(seconds=30) < end - start < datetime.timedelta(seconds=32):
my_logger.logger.warning(f'Warning! Heartbeat difference is {end - start}')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ок гугль, як потім з логу зрозуміти коли сталася ця різниця? (те ж з ерором)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, тут згоден, тут треба додати час удару до логу

@Dudnik-Denys
Copy link
Contributor Author

Трохи переробив, тепер шукаємо дату за ключем Timestamp, та у лозі бачимо час коли в нас сталися варнінги чи ерори.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants