Wallet config debugging. More.
This commit is contained in:
parent
07134d26d7
commit
7ff426f9ba
|
@ -20,22 +20,34 @@ class logger:
|
|||
GREEN = '\033[92m'
|
||||
BLUE = '\033[94m'
|
||||
RESET = '\033[0m'
|
||||
LOG_FILE = '/opt/clore-hosting/clore_onboarding.log'
|
||||
|
||||
@staticmethod
|
||||
def _get_current_time():
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
@staticmethod
|
||||
def _log_to_file(level, message):
|
||||
try:
|
||||
with open(logger.LOG_FILE, 'a') as f:
|
||||
f.write(f"{logger._get_current_time()} | {level} | {message}\n")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def error(message):
|
||||
print(f"{logger.RED}{logger._get_current_time()} | ERROR | {message}{logger.RESET}")
|
||||
logger._log_to_file("ERROR", message)
|
||||
|
||||
@staticmethod
|
||||
def success(message):
|
||||
print(f"{logger.GREEN}{logger._get_current_time()} | SUCCESS | {message}{logger.RESET}")
|
||||
logger._log_to_file("SUCCESS", message)
|
||||
|
||||
@staticmethod
|
||||
def info(message):
|
||||
print(f"{logger.BLUE}{logger._get_current_time()} | INFO | {message}{logger.RESET}")
|
||||
logger._log_to_file("INFO", message)
|
||||
|
||||
if os.geteuid() != 0:
|
||||
logger.error("This script must be run as root!")
|
||||
|
|
Loading…
Reference in New Issue