Codebase list fudgec2 / 57bb8f5 Data / Logging.py
57bb8f5

Tree @57bb8f5 (Download .tar.gz)

Logging.py @57bb8f5raw · history · blame

class Logging():
    # -- Basic text file logging via decorator.
    # -- This should be updated to support logging to sqlite.
    logfile = "Storage/log.txt"


    def log(self, tag_name):
        def tags_decorator(func):
            def func_wrapper(*args, **kwargs):
                result = func(*args, **kwargs)
                with open(self.logfile,'a+') as logfile:
                    logfile.write("{}{}\n".format(tag_name,result ))
                return result
            return func_wrapper
        return tags_decorator


    def __Database_Write__(self, values):
        if type(values) != dict or 'type' not in values or 'data' not in values:
            return False
    # -- Trialing decortator SQL logging
    def log_login(self, tag_name):
        def tags_decorator(func):
            def func_wrapper(*args, **kwargs):
                result = func(*args, **kwargs)
                with open(self.logfile,'a+') as logfile:
                    logfile.write("{}{}\n".format(tag_name,result ))
                return result
            return func_wrapper
        return tags_decorator