# Path: hub_toolbox/htlogging.py
# class Logging(metaclass=ABCMeta): # pragma: no cover
#     """Base class for time-stamped logging.
#     
#     Do not instantiate this class, but ConsoleLogging or FileLogging!
#     """
#     @property
#     def _current_time(self):
#         """Formatted time stamp"""
#         return time.strftime('%Y-%m-%d %H:%M:%S')
#     
#     @abstractmethod
#     def message(self):
#         ...
#     @abstractmethod
#     def warning(self):
#         ...
#     @abstractmethod
#     def error(self):
#         ...
# 
# class ConsoleLogging(Logging):
#     """Convenience functions for time-stamped logging to the console"""
# 
#     def message(self, *objs, flush=True):
#         """Log normal program function"""
#         print(self._current_time, 'INFO:', *objs)
#         if flush:
#             sys.stdout.flush()
# 
#     def warning(self, *objs, flush=True):
#         """Log warning (program can still continue)"""
#         print(self._current_time, 'WARNING:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()
# 
#     def error(self, *objs, flush=True):
#         """Log error (program fails)"""
#         print(self._current_time, 'ERROR:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()
# 
# class FileLogging(ConsoleLogging):
#     """Convenience functions for time-stamped logging to a file"""
# 
#     def __init__(self):
#         """Not implemented"""
#         self.warning("FileLogging not yet implemented, will print to "
#                      "console anyway.")


import unittest
from hub_toolbox.htlogging import Logging, ConsoleLogging, FileLogging
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file is part of the HUB TOOLBOX available at
https://github.com/OFAI/hub-toolbox-python3/
The HUB TOOLBOX is licensed under the terms of the GNU GPLv3.

(c) 2016-2018, Roman Feldbauer
Austrian Research Institute for Artificial Intelligence (OFAI)
Contact: <roman.feldbauer@ofai.at>
"""

class TestLogging(unittest.TestCase):
    """Minimally test Logging (should switch to std module logging anyway)"""

    def test_unable_to_instantiate_abstract_class_logging(self):
        with self.assertRaises(TypeError):
            Logging()

    def test_console_logging_has_all_methods(self):
        log = ConsoleLogging()
        has_all_attributes = hasattr(log, 'warning') and \
            hasattr(log, 'warning') and hasattr(log, 'error')
        return self.assertTrue(has_all_attributes)

    def test_file_logging_has_all_methods(self):

# Path: hub_toolbox/htlogging.py
# class Logging(metaclass=ABCMeta): # pragma: no cover
#     """Base class for time-stamped logging.
#     
#     Do not instantiate this class, but ConsoleLogging or FileLogging!
#     """
#     @property
#     def _current_time(self):
#         """Formatted time stamp"""
#         return time.strftime('%Y-%m-%d %H:%M:%S')
#     
#     @abstractmethod
#     def message(self):
#         ...
#     @abstractmethod
#     def warning(self):
#         ...
#     @abstractmethod
#     def error(self):
#         ...
# 
# class ConsoleLogging(Logging):
#     """Convenience functions for time-stamped logging to the console"""
# 
#     def message(self, *objs, flush=True):
#         """Log normal program function"""
#         print(self._current_time, 'INFO:', *objs)
#         if flush:
#             sys.stdout.flush()
# 
#     def warning(self, *objs, flush=True):
#         """Log warning (program can still continue)"""
#         print(self._current_time, 'WARNING:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()
# 
#     def error(self, *objs, flush=True):
#         """Log error (program fails)"""
#         print(self._current_time, 'ERROR:', *objs, file=sys.stderr)
#         if flush:
#             sys.stderr.flush()
# 
# class FileLogging(ConsoleLogging):
#     """Convenience functions for time-stamped logging to a file"""
# 
#     def __init__(self):
#         """Not implemented"""
#         self.warning("FileLogging not yet implemented, will print to "
#                      "console anyway.")


# Path: tests/logging_test.py
import unittest
from hub_toolbox.htlogging import Logging, ConsoleLogging, FileLogging

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file is part of the HUB TOOLBOX available at
https://github.com/OFAI/hub-toolbox-python3/
The HUB TOOLBOX is licensed under the terms of the GNU GPLv3.

(c) 2016-2018, Roman Feldbauer
Austrian Research Institute for Artificial Intelligence (OFAI)
Contact: <roman.feldbauer@ofai.at>
"""

class TestLogging(unittest.TestCase):
    """Minimally test Logging (should switch to std module logging anyway)"""

    def test_unable_to_instantiate_abstract_class_logging(self):
        with self.assertRaises(TypeError):
            Logging()

    def test_console_logging_has_all_methods(self):
        log = ConsoleLogging()
        has_all_attributes = hasattr(log, 'warning') and \
            hasattr(log, 'warning') and hasattr(log, 'error')
        return self.assertTrue(has_all_attributes)

    def test_file_logging_has_all_methods(self):

        log = FileLogging()