SHARE
TWEET

Untitled

a guest Jun 26th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - src/
  2.    |-- classes/
  3.       |-- Logger.py
  4.       |-- Browser.py
  5.    |-- ubigeo.py
  6. - main.py
  7.      
  8. #Logger.py
  9. import logging, logstash
  10.  
  11. class LoggerSingleton:
  12.   _shared_state = {}
  13.  
  14.   def __init__(self):
  15.     self.__dict__ = self._shared_state
  16.  
  17. class Logger(LoggerSingleton):
  18.   def __init__(self):
  19.     LoggerSingleton.__init__(self)
  20.     self.logger = self.init_console_logger()
  21.  
  22.   def init_console_logger(self):
  23.     logger = logging.getLogger('python-logstash-logger')
  24.     logger.setLevel('DEBUG')
  25.  
  26.     formatter = logging.Formatter('%(asctime)s : %(levelname)s : %(message)s')
  27.  
  28.     sh = logging.StreamHandler()
  29.     sh.setLevel(logging.INFO)
  30.     sh.setFormatter(formatter)
  31.  
  32.     logger.addHandler(sh)
  33.  
  34.     return logger
  35.  
  36.   def log(self, message):
  37.     self.logger.info(message)
  38.      
  39. #main.py
  40. from src.classes import Logger
  41.  
  42. if __name__ == "__main__":
  43.   logger_handler = Logger()
  44.   logger_handler.log('Checking python version...')
  45.  
  46.   ubigeo.main()
  47.      
  48. #Browser.py
  49. from .Logger import Logger
  50.  
  51. class Browser(Config, Logger):
  52.   self.logger = Logger()
  53.   self.logger.log('Setting up & launching a browser')
  54.      
  55. #ubigeo.py
  56. from .classes.Browser import Browser
  57.  
  58. def main():
  59.   browser_handler = Browser()
  60.      
  61. 2019-04-21 13:25:12,758 : INFO : Checking python version...
  62. 2019-04-21 13:25:12,915 : INFO : Setting up & launching a browser
  63. 2019-04-21 13:25:12,915 : INFO : Setting up & launching a browser
  64.      
  65. 2019-04-21 13:25:12,758 : INFO : Checking python version...
  66. 2019-04-21 13:25:12,915 : INFO : Setting up & launching a browser
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top