content: import logging
  import sys
  
  class CustomFormatter(logging.Formatter):
      """Logging Formatter to add colors and count warning / errors"""
  
      grey = "\x1b[38;21m"
      yellow = "\x1b[33;21m"
      red = "\x1b[31;21m"
      bold_red = "\x1b[31;1m"
      reset = "\x1b[0m"
      format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
  
      FORMATS = {
          logging.DEBUG: grey + format + reset,
          logging.INFO: grey + format + reset,
          logging.WARNING: yellow + format + reset,
          logging.ERROR: red + format + reset,
          logging.CRITICAL: bold_red + format + reset
      }
  
      def format(self, record):
          log_fmt = self.FORMATS.get(record.levelno)
          formatter = logging.Formatter(log_fmt)
          return formatter.format(record)
  
  # create logger with 'spam_application'
  logger = logging.getLogger("Sample")
  
  # create console handler with a higher log level
  ch = logging.StreamHandler()
  ch.setLevel(logging.DEBUG)
  
  if len(sys.argv)> 1:
      if sys.argv[1] == 'log':
          ch.setFormatter(logging.Formatter('%(asctime)s : %(levelname)s : %(name)s : %(message)s'))
      elif sys.argv[1] == 'color':
          ch.setFormatter(CustomFormatter())
  
  if len(sys.argv) > 2:
      logger.setLevel(logging.__getattribute__(sys.argv[2]))
  else:
      logger.setLevel(logging.DEBUG)
  
  logger.addHandler(ch)
  
  # logger.debug("debug message")
  # logger.info("info message")
  # logger.warning("warning message")
  # logger.error("error message")
  # logger.critical("critical message")
  
  import random
  import time
  for _ in range(100):
      i = random.randint(0, 10)
      if i <= 4:
          logger.info("Value is {} - Everything is fine".format(i))
      elif i <= 6:
          logger.warning("Value is {} - System is getting hot".format(i))
      elif i <= 8:
          logger.error("Value is {} - Dangerous region".format(i))
      else:
          logger.critical("Maximum value reached")
      time.sleep(0.3)
  
  