Codebase list fudgec2 / 9efa3053-3ebd-43b9-ba52-25607284fb4a/upstream Data / Logging.py
9efa3053-3ebd-43b9-ba52-25607284fb4a/upstream

Tree @9efa3053-3ebd-43b9-ba52-25607284fb4a/upstream (Download .tar.gz)

Logging.py @9efa3053-3ebd-43b9-ba52-25607284fb4a/upstreamraw · 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