loraSMS / userio.py /
Yanik Cawidrone Push everything
cbf75b6 a year ago
1 contributor
60 lines | 2.49kb
#
# Copyright (C) Actility, SA. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version
# 2 only, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License version 2 for more details (a copy is
# included at /legal/license.txt).
#
# You should have received a copy of the GNU General Public License
# version 2 along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
#
# Please contact Actility, SA.,  4, rue Ampere 22300 LANNION FRANCE
# or visit www.actility.com if you need additional
# information or have any questions.
#
from colorama import Fore, Back, Style
from time import gmtime, strftime

name = "LoRaSMS"

def say(message):
  date_string = strftime("%Y-%m-%d %H:%M:%S %z", gmtime())
  prefix = Fore.CYAN + name + " " + Fore.RESET + date_string + " "
  print(prefix + Style.DIM + message + Style.RESET_ALL)


def ok(message, detail=""):
  date_string = strftime("%Y-%m-%d %H:%M:%S %z", gmtime())
  level = Fore.GREEN + "[OK] " + Fore.RESET
  prefix = Fore.CYAN + name + " " + Fore.RESET + date_string + " "
  print(prefix + level + Style.BRIGHT + message + Style.RESET_ALL + " " + detail + Style.RESET_ALL)


def warn(message, detail=""):
  date_string = strftime("%Y-%m-%d %H:%M:%S %z", gmtime())
  prefix = Fore.CYAN + name + " " + Fore.RESET + date_string + " "
  level = Fore.YELLOW + "[WARN] " + Fore.RESET
  print(prefix  + level +  Style.BRIGHT + message + Style.RESET_ALL + " " + detail + Style.RESET_ALL)


def error(message, detail=""):
  date_string = strftime("%Y-%m-%d %H:%M:%S %z", gmtime())
  prefix = Fore.CYAN + name + " " + Fore.RESET + date_string + " "
  level = Fore.RED + "[ERR] " + Fore.RESET
  print(prefix + level +  Style.BRIGHT + message + Style.RESET_ALL + " " + detail + Style.RESET_ALL)


def debug(message, detail=""):
  date_string = strftime("%Y-%m-%d %H:%M:%S %z", gmtime())
  prefix = Fore.CYAN + name + " " + Fore.RESET + date_string + " "
  level = Fore.MAGENTA + "[DEBUG] " + Fore.RESET
  print(prefix + level +  Style.DIM + message + Style.RESET_ALL + " " + detail + Style.RESET_ALL)