diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-18 02:22:36 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-18 02:22:36 +0300 |
commit | f39f18c94060642859900bdb04cb4df2164bc8b4 (patch) | |
tree | eb29d7577e95c32a0894c134214b86db44c3b074 /vk/utils/tracking/db/writer/log.py | |
parent | refactoring (diff) | |
download | vk-scripts-f39f18c94060642859900bdb04cb4df2164bc8b4.tar.gz vk-scripts-f39f18c94060642859900bdb04cb4df2164bc8b4.zip |
put format-specific db writers/readers together
Diffstat (limited to 'vk/utils/tracking/db/writer/log.py')
-rw-r--r-- | vk/utils/tracking/db/writer/log.py | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/vk/utils/tracking/db/writer/log.py b/vk/utils/tracking/db/writer/log.py deleted file mode 100644 index faef29b..0000000 --- a/vk/utils/tracking/db/writer/log.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2016 Egor Tensin <Egor.Tensin@gmail.com> -# This file is licensed under the terms of the MIT License. -# See LICENSE.txt for details. - -import logging - -class Logger: - @staticmethod - def on_initial_status(user): - if user.is_online(): - logging.info(Logger._format_user_is_online(user)) - else: - logging.info(Logger._format_user_is_offline(user)) - logging.info(Logger._format_user_last_seen(user)) - - @staticmethod - def on_status_update(user): - if user.is_online(): - logging.info(Logger._format_user_went_online(user)) - else: - logging.info(Logger._format_user_went_offline(user)) - logging.info(Logger._format_user_last_seen(user)) - - @staticmethod - def on_connection_error(e): - #logging.exception(e) - pass - - @staticmethod - def _format_user(user): - if user.has_last_name(): - return '{} {}'.format(user.get_first_name(), user.get_last_name()) - else: - return '{}'.format(user.get_first_name()) - - @staticmethod - def _format_user_is_online(user): - return '{} is ONLINE.'.format(Logger._format_user(user)) - - @staticmethod - def _format_user_is_offline(user): - return '{} is OFFLINE.'.format(Logger._format_user(user)) - - @staticmethod - def _format_user_last_seen(user): - return '{} was last seen at {} using {}.'.format( - Logger._format_user(user), - user.get_last_seen_time_local(), - user.get_last_seen_platform().get_description_for_sentence()) - - @staticmethod - def _format_user_went_online(user): - return '{} went ONLINE.'.format(Logger._format_user(user)) - - @staticmethod - def _format_user_went_offline(user): - return '{} went OFFLINE.'.format(Logger._format_user(user)) |