Codebase list fudgec2 / 1f9bc85d-cf5d-4190-896e-9f2bdd91491b/upstream Data / Logging.py
1f9bc85d-cf5d-4190-896e-9f2bdd91491b/upstream

Tree @1f9bc85d-cf5d-4190-896e-9f2bdd91491b/upstream (Download .tar.gz)

Logging.py @1f9bc85d-cf5d-4190-896e-9f2bdd91491b/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