"""
Name: system_logger
Title: System Logger
Author: Cooper
Date: 30/09/2021

Desc:  Allows the application to contribute to the system log thus providing some useful debug without much faffing
about.

This would be a good place to put any other logging business.

"""

import subprocess

class SysLogger():
    @staticmethod
    def log_to_system(module, message):
        """
        Appends to the system log which can be accessed using logread -e onionApp

        Example log entry:
        Wed Sep 29 12:33:05 2021 user.notice root: onionApp.SysLogger.Test Hi!
        """
        command = ["logger", "onionApp.%s" % module, message]

        process = subprocess.Popen(command, stdout=subprocess.PIPE)
        output, error = process.communicate()

if __name__ == "__main__":
    SysLogger.log_to_system("SysLogger.Test", "Test Message")
