def get_logger(): # creating a folder for logs if it is not available full_path_to_logs = os.path.join(conf.work_path, conf.dir_log) if not os.path.exists(full_path_to_logs): os.mkdir(full_path_to_logs) full_path_to_logs = os.path.join(full_path_to_logs, conf.name_log_file) # initialization of logger logger = logging.getLogger(str(__file__)[:-3]) # creating a handler that writes to a file and re-creates it in time handler = TimedRotatingFileHandler( full_path_to_logs, when=conf.period_create_new_log_file, backupCount=conf.log_backup_count) handler.setLevel(logging.INFO) handler.setFormatter(logging.Formatter(conf.format_logger)) logger.addHandler(handler) # creating a handler that is necessary for logging when starting the module via systemctl log = journal.JournalHandler() log.setLevel(logging.INFO) log.setFormatter(logging.Formatter(conf.format_logger)) logger.addHandler(log) logger.setLevel(logging.INFO) return logger
def init_logging(conf): """ Initializes logging according to configuration file. """ log_format = '%(levelname)s - %(message)s' log_backend = conf.log_backend if not log_backend or len(log_backend) == 0 or log_backend == "console": logging.basicConfig(level=conf.log_level, format=log_format) log = logging.getLogger() log.setLevel(conf.log_level) elif log_backend == "journal": logging.basicConfig(level=conf.log_level, format=log_format) try: from systemd import journal except ImportError: raise ValueError("systemd.journal module is not installed") log = logging.getLogger() log.propagate = False log.addHandler(journal.JournalHandler()) else: logging.basicConfig(filename=conf.log_file, level=conf.log_level, format=log_format) log = logging.getLogger()
def log_handlers(self): # Log formats if self.systemd: _jrnlfmt = logging.Formatter(fmt=('{levelname}: {message} ' + '({filename}:{lineno})'), style='{', datefmt='%Y-%m-%d %H:%M:%S') _logfmt = logging.Formatter(fmt=('{asctime}:{levelname}: {message} (' + '{filename}:{lineno})'), style='{', datefmt='%Y-%m-%d %H:%M:%S') # Add handlers _dflthandler = logging.handlers.RotatingFileHandler( self.logfile, encoding='utf8', # 1GB maxBytes=1073741824, backupCount=5) _dflthandler.setFormatter(_logfmt) _dflthandler.setLevel(self.loglvls[self.loglvl]) if self.systemd: from systemd import journal try: h = journal.JournaldLogHandler() except AttributeError: # Uses the other version h = journal.JournalHandler() h.setFormatter(_jrnlfmt) h.setLevel(self.loglvls[self.loglvl]) self.Logger.addHandler(h) self.Logger.addHandler(_dflthandler) self.Logger.info('Logging initialized') return ()
def test_journalhandler_no_message_id(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) sender = MockSender() handler = journal.JournalHandler(logging.INFO, sender_function=sender.send) handler.emit(record) assert len(sender.buf) == 1 assert all(not m.startswith('MESSAGE_ID=') for m in sender.buf[0])
def configure_logger(log_filename=None, no_journald_log=False): logger.setLevel(logging.DEBUG) # apt-get reconfigures pty somehow, so CR symbol becomes necessary in stdout, # so it is added to logging format string here # logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s: %(message)s\r') fmt = logging.Formatter(fmt='%(asctime)s %(message)s\r', datefmt='%H:%M:%S') stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler.setFormatter(fmt) stdout_handler.setLevel(logging.INFO) logger.addHandler(stdout_handler) if log_filename: file_fmt = logging.Formatter( '%(asctime)s %(name)s %(levelname)s: %(message)s') os.makedirs(os.path.dirname(log_filename), exist_ok=True) file_handler = logging.FileHandler(log_filename) file_handler.setFormatter(file_fmt) file_handler.setLevel(logging.DEBUG) logger.addHandler(file_handler) logger.info('Update log is written to {}'.format(log_filename)) if not no_journald_log: journald_handler = journal.JournalHandler( SYSLOG_IDENTIFIER='wb-release') journald_handler.setLevel(logging.INFO) logger.addHandler(journald_handler) logger.info('journald logging enabled')
def test_journalhandler_info(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) sender = MockSender() kw = {'X': 3, 'X3': 4, 'sender_function': sender.send} handler = journal.JournalHandler(logging.INFO, **kw) handler.emit(record) assert len(sender.buf) == 1 assert 'X=3' in sender.buf[0] assert 'X3=4' in sender.buf[0] sender = MockSender() handler = journal.JournalHandler.with_args({ 'level': logging.INFO, 'X': 3, 'X3': 4, 'sender_function': sender.send }) handler.emit(record) assert len(sender.buf) == 1 assert 'X=3' in sender.buf[0] assert 'X3=4' in sender.buf[0] # just check that args==None doesn't cause an error journal.JournalHandler.with_args()
def get_journal_handler(cls): if cls._journal_handler is None and journal: cls._journal_handler = journal.JournalHandler() cls._journal_handler.setLevel(cls._level) cls._journal_handler.setFormatter( logging.Formatter(JOURNAL_LOG_FORMAT if cls._level != logging. DEBUG else DEBUG_FORMAT)) return cls._journal_handler
def test_journalhandler_message_id_on_handler_hex(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) sender = MockSender() handler = journal.JournalHandler(logging.INFO, sender_function=sender.send, MESSAGE_ID=TEST_MID.hex) handler.emit(record) assert len(sender.buf) == 1 assert 'MESSAGE_ID=' + TEST_MID.hex in sender.buf[0]
def add_log_handler(lvl, fmt): try: from systemd import journal h = journal.JournalHandler(SYSLOG_IDENTIFIER=config.PACKAGE_NAME) except: h = logging.StreamHandler() h.setLevel(lvl) h.setFormatter(logging.Formatter(fmt)) log.addHandler(h)
def setup_logging(args): if (args['--debug']): stream_handler = StreamHandler(sys.stdout) stream_handler.setLevel(logging.DEBUG) logging.root.addHandler(stream_handler) handler = journal.JournalHandler(SYSLOG_IDENTIFIER='cns-daemon-siiuf') handler.setLevel(logging.DEBUG) logging.root.addHandler(handler)
def test_journalhandler_info(): record = logging.LogRecord('test-logger', logging.INFO, 'testpath', 1, 'test', None, None) sender = MockSender() kw = {'X':3, 'X3':4, 'sender_function': sender.send} handler = journal.JournalHandler(logging.INFO, **kw) handler.emit(record) assert len(sender.buf) == 1 assert 'X=3' in sender.buf[0] assert 'X3=4' in sender.buf[0]
def get_default_handler(): handler = logging.StreamHandler(sys.stderr) # Detect systemd journal with contextlib.suppress(ValueError, io.UnsupportedOperation): journal_dev, journal_ino = map( int, os.environ.get("JOURNAL_STREAM", "").split(":")) st = os.fstat(sys.stderr.fileno()) if (journal and st.st_dev == journal_dev and st.st_ino == journal_ino): handler = journal.JournalHandler(SYSLOG_IDENTIFIER=LOGGER_NAME) return handler
def configure_logging(self, multi_threaded, level): if os.isatty(sys.stdout.fileno()): # stdout logging is only enabled for user tty sessions logging.basicConfig(level=level, format=LOG_FORMAT) else: journal_handler = journal.JournalHandler(SYSLOG_IDENTIFIER=self.name) journal_handler.setLevel(level) journal_handler.setFormatter(logging.Formatter( LOG_FORMAT_JOURNAL_MULTI_THREAD if multi_threaded else LOG_FORMAT_JOURNAL)) logging.root.addHandler(journal_handler) logging.root.setLevel(level)
def _set_logger(): """ Set the logging schema """ log = logging.getLogger(__name__) log.propagate = False log.setLevel(logging.DEBUG) formatter = logging.Formatter("%(name)s %(message)s") jhandler = journal.JournalHandler() jhandler.setLevel(logging.DEBUG) jhandler.setFormatter(formatter) log.addHandler(jhandler) return log
def __setup_logging(loglevel, frm, startmethode, unitname): """ Erstellt die Logger Instanz für das Skript """ logger = logging.getLogger() logger.setLevel(loglevel) logger.handlers = [] if startmethode == "auto": log_handler = journal.JournalHandler(SYSLOG_IDENTIFIER=unitname) else: log_handler = logging.StreamHandler() log_handler.setLevel(loglevel) log_handler.setFormatter(frm) logger.addHandler(log_handler) return logger
def _setup_logging(self): log_level = self._conf.get("app", "log_level") mdbx_logger = logging.getLogger("maestral") mdbx_logger.setLevel(logging.DEBUG) log_fmt_long = logging.Formatter( fmt="%(asctime)s %(name)s %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S") log_fmt_short = logging.Formatter(fmt="%(message)s") # log to file rfh_log_file = get_log_path("maestral", self._config_name + ".log") self._log_handler_file = logging.handlers.RotatingFileHandler( rfh_log_file, maxBytes=10**7, backupCount=1) self._log_handler_file.setFormatter(log_fmt_long) self._log_handler_file.setLevel(log_level) mdbx_logger.addHandler(self._log_handler_file) # log to journal when launched from systemd if INVOCATION_ID and journal: self._log_handler_journal = journal.JournalHandler() self._log_handler_journal.setFormatter(log_fmt_short) mdbx_logger.addHandler(self._log_handler_journal) # log to stdout (disabled by default) self._log_handler_stream = logging.StreamHandler(sys.stdout) self._log_handler_stream.setFormatter(log_fmt_long) self._log_handler_stream.setLevel(100) mdbx_logger.addHandler(self._log_handler_stream) # log to cached handlers for GUI and CLI self._log_handler_info_cache = CachedHandler(maxlen=1) self._log_handler_info_cache.setLevel(logging.INFO) self._log_handler_info_cache.setFormatter(log_fmt_short) mdbx_logger.addHandler(self._log_handler_info_cache) self._log_handler_error_cache = CachedHandler() self._log_handler_error_cache.setLevel(logging.ERROR) self._log_handler_error_cache.setFormatter(log_fmt_short) mdbx_logger.addHandler(self._log_handler_error_cache) # log to bugsnag (disabled by default) self._log_handler_bugsnag = BugsnagHandler() self._log_handler_bugsnag.setLevel(100) mdbx_logger.addHandler(self._log_handler_bugsnag)
def log(self, value): """log: логирование результатов работы, может принимать значения: False - не вести лог log - экземпляр logging.Logger system - записть в системный лог systemd stdout - вывод в стандартный поток или принимает имя файла для записи лога """ if isinstance(value, logging.Logger): self.__logger = value return None journalName = 'minigstatistic' timeformat = "%Y.%m.%d-%H:%M:%S" self.__logger = logging.getLogger(journalName) self.__logger.setLevel(logging.INFO) if value == 'False': # Не вести лог handler = logging.NullHandler() formatter = logging.Formatter() elif value == 'journal': # Запись лога в системный журнал handler = journal.JournalHandler(SYSLOG_IDENTIFIER=journalName) formatter = logging.Formatter('%(levelname)s: %(message)s') elif value == 'stdout': # Вывод лога в stdout handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter( '[%(asctime)s] %(name)s: %(levelname)s: %(message)s', timeformat, ) else: # Запись лога в файл handler = logging.FileHandler(value) formatter = logging.Formatter( '[%(asctime)s] %(name)s: %(levelname)s: %(message)s', timeformat, ) handler.setLevel(logging.INFO) handler.setFormatter(formatter) self.__logger.addHandler(handler)
def __setup_logging(loglevel, frm, startmethode, unitname, pfad): """ Erstellt die Logger Instanz für das Skript """ logger = logging.getLogger() logger.setLevel(loglevel) logger.handlers = [] if startmethode == "auto": log_handler = journal.JournalHandler(SYSLOG_IDENTIFIER=unitname) else: fehlerlog = os.path.join(pfad, "{}.log".format(unitname)) log_handler = logging.FileHandler(fehlerlog) log_handler.setLevel(loglevel) log_handler.setFormatter(frm) logger.addHandler(log_handler) return logger
def main(): # Send logging messages both to the console and the journal logging.basicConfig(level=logging.INFO) logging.root.addHandler(journal.JournalHandler()) parser = argparse.ArgumentParser() parser.add_argument('--debug', dest='debug', action='store_true') parser.add_argument('--app-id', dest='app_id', help='Flatpak App ID', type=str, required=True) parser.add_argument('--remote', dest='remote', help='Flatpak Remote', type=str, required=True) parser.add_argument('--branch', dest='branch', help='Flatpak Branch', type=str, default='', required=False) parser.add_argument('--required-archs', dest='required_archs', default=[], nargs='*', type=str) parsed_args = parser.parse_args() if parsed_args.debug: logging.root.setLevel(logging.DEBUG) if parsed_args.required_archs and Flatpak.get_default_arch( ) not in parsed_args.required_archs: exit_with_error( "Found installation of unsupported architecture: {}".format( parsed_args.required_archs)) InstallAppHelperInstaller(parsed_args.app_id, parsed_args.remote, parsed_args.branch) sys.exit(0)
def main(): """ Entry point. Start reading from stdin for pop shell commands. """ # Try to log directly to journalctl, and fallback to stderr logging which # also gets directed to journalctl by Pop Shell try: from systemd import journal # pylint: disable=import-outside-toplevel log.addHandler(journal.JournalHandler()) except ImportError: logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) log.setLevel(logging.WARNING) log.info("VScode workspace plugin started, see " "https://github.com/lunaryorn/pop-shell-launcher-vscode") vscode = find_vscode() if vscode: log.info("Found vscode %s, config dir %s", vscode.app_info, vscode.config_dir) event_handler = EventHandlers(vscode, vscode.get_recent_workspaces()) else: log.warning( "VSCode not found! To add support for your variant of VSCode make " "a pull request at " "https://github.com/lunaryorn/pop-shell-launcher-vscode/pulls") event_handler = None for line in sys.stdin: event = json.loads(line) log.debug("Got event: %r", event) assert isinstance(event, dict) if event_handler: response = event_handler(event) else: response = noop() log.debug("Replying with %r", response) write_response(response)
def __init__(self, uuid, config_dir="/etc/turku-storage"): self.arg_uuid = uuid self.config = load_config(config_dir) for k in ("name", "secret"): if k not in self.config: raise Exception("Incomplete config") self.logger = logging.getLogger(self.config["name"]) self.logger.setLevel(logging.DEBUG) self.lh_console = logging.StreamHandler() self.lh_console_formatter = logging.Formatter( "[%(asctime)s %(name)s] %(levelname)s: %(message)s") self.lh_console.setFormatter(self.lh_console_formatter) self.lh_console.setLevel(logging.ERROR) self.logger.addHandler(self.lh_console) if self.config["log_file"] == "systemd" and (not isinstance( systemd_journal, ImportError)): self.lh_local = systemd_journal.JournalHandler( SYSLOG_IDENTIFIER="turku-storage-ping") self.lh_local_formatter = logging.Formatter( "%(name)s {}: %(message)s".format(self.arg_uuid)) elif self.config["log_file"] == "syslog": self.lh_local = logging.handlers.SysLogHandler() self.lh_local_formatter = logging.Formatter( "{} turku-storage-ping[%(process)s] %(name)s {}: %(message)s". format(platform.node(), self.arg_uuid)) elif self.config["log_file"]: self.lh_local = logging.FileHandler(self.config["log_file"]) self.lh_local_formatter = logging.Formatter( "%(asctime)s " + platform.node() + " turku-storage-ping[%(process)s] (%(name)s) " + self.arg_uuid + ": %(message)s") else: self.lh_local = None self.lh_local_formatter = None if self.lh_local: self.lh_local.setFormatter(self.lh_local_formatter) self.lh_local.setLevel(logging.DEBUG) self.logger.addHandler(self.lh_local)
def main(): # Send logging messages both to the console and the journal logging.basicConfig(level=logging.INFO) logging.root.addHandler(journal.JournalHandler()) parser = argparse.ArgumentParser() parser.add_argument('--debug', dest='debug', action='store_true') parsed_args = parser.parse_args() if parsed_args.debug: logging.root.setLevel(logging.DEBUG) app_arch = Flatpak.get_default_arch() if app_arch != 'x86_64': exit_with_error("Found installation of unsupported architecture: %s", app_arch) GoogleChromeInstaller() sys.exit(0)
def __init__(self, *args, **kw): super(GithubConsumer, self).__init__(*args, **kw) self.log = logging.getLogger(self.config_key) journal_handler = journal.JournalHandler() journal_handler.setFormatter( logging.Formatter("[%(name)s %(levelname)s]: %(message)s")) self.log.addHandler(journal_handler) if args[0].config.get("{}.debug".format(self.config_key)): self.log.setLevel(logging.DEBUG) else: self.log.setLevel(logging.INFO) self.topic_mapping = { 'org.fedoraproject.prod.github.issue.comment': self.issue_comment, 'org.fedoraproject.prod.github.issue.labeled': self.issue_labeled, 'org.fedoraproject.prod.github.pull_request.edited': self.pr_edited, 'org.fedoraproject.prod.github.pull_request.opened': self.pr_opened, 'org.fedoraproject.prod.github.pull_request.reopened': self.pr_reopened, 'org.fedoraproject.prod.github.pull_request.closed': self.pr_closed, 'org.fedoraproject.prod.github.pull_request.synchronize': self.pr_synchronize, 'org.fedoraproject.prod.github.pull_request.review_comment': self.pr_review, 'org.fedoraproject.prod.github.pull_request.labeled': self.pr_labeled, 'org.fedoraproject.prod.github.pull_request.unlabeled': self.pr_unlabeled, 'org.fedoraproject.prod.github.status': self.status, } self.formatter = self.formatter_cls( self.project, args[0].config["{}.email_to".format(self.config_key)], args[0].config["{}.email_from".format(self.config_key)], args[0].config["{}.smtp_server".format(self.config_key)], log=self.log)
def log(self, value): """log: логирование результатов работы, может принимать значения: False - не вести лог system - записть в системный лог systemd stdout - вывод в стандартный поток или принимает имя файла для записи лога""" journalName = os.path.basename( __file__) if __name__ == "__main__" else __name__ timeformat = "%Y.%m.%d-%H:%M:%S" self.__logger = logging.getLogger(journalName) self.__logger.setLevel(logging.INFO) if value == 'False': # Не вести лог handler = logging.NullHandler() formatter = logging.Formatter() elif value == 'journal': # Запись лога в системный журнал handler = journal.JournalHandler(SYSLOG_IDENTIFIER=journalName) formatter = logging.Formatter('%(levelname)s: %(message)s') elif value == 'stdout': # Вывод лога в stdout handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter( '[%(asctime)s] %(name)s: %(levelname)s: %(message)s', timeformat) else: # Запись лога в файл handler = logging.FileHandler(value) formatter = logging.Formatter( '[%(asctime)s] %(name)s: %(levelname)s: %(message)s', timeformat) handler.setLevel(logging.INFO) handler.setFormatter(formatter) self.__logger.addHandler(handler)
def logger_init(tag, dest, level): """ Initialize the logger """ logger = logging.getLogger("winelauncher") logger.setLevel(set_log_level(level)) if dest == "journal": log_handler = journal.JournalHandler(SYSLOG_IDENTIFIER=tag) log_format = logging.Formatter("%(levelname)-8s - %(message)s") elif dest == "console": log_handler = logging.StreamHandler() log_format = logging.Formatter( "%(asctime)s - %(levelname)-8s - %(message)s") else: try: log_handler = logging.FileHandler(dest) log_format = logging.Formatter( "%(asctime)s %(levelname)-8s {} %(message)s".format(tag)) except OSError as err: print("Cannot open file {}".format(dest)) print("OSError: {0}".format(err)) log_handler.setFormatter(log_format) logger.addHandler(log_handler) return logger
pass # create logger with 'Relay-Controller' logger = logging.getLogger('Relay-Controller') logger.setLevel(logging.DEBUG) logger.propagate = False # Fixes double log to journal # create file handler which logs even debug messages ih = RotatingFileHandler(filename=file_log_info, backupCount=1, maxBytes=5 * 1024 * 1024) ih.setLevel(logging.DEBUG) # create file handler with a higher log level eh = RotatingFileHandler(filename=file_log_error, backupCount=1, maxBytes=5 * 1024 * 1024) eh.setLevel(logging.ERROR) # create journal handler # jh = logging.StreamHandler() jh = journal.JournalHandler() jh.setLevel(logging.DEBUG) # create formatter and add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ih.setFormatter(formatter) eh.setFormatter(formatter) jh.setFormatter(logging.Formatter('%(levelname)s - %(message)s')) # add the handlers to the logger logger.addHandler(ih) logger.addHandler(eh) logger.addHandler(jh)
def _setup_logging(self): """ Sets up logging to log files, status and error properties, desktop notifications, the systemd journal if available, bugsnag if error reports are enabled, and to stdout if requested. """ log_level = self._conf.get('app', 'log_level') mdbx_logger = logging.getLogger('maestral') mdbx_logger.setLevel(logging.DEBUG) log_fmt_long = logging.Formatter( fmt='%(asctime)s %(name)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') log_fmt_short = logging.Formatter(fmt='%(message)s') # log to file rfh_log_file = get_log_path('maestral', self._config_name + '.log') self.log_handler_file = logging.handlers.RotatingFileHandler( rfh_log_file, maxBytes=10**7, backupCount=1) self.log_handler_file.setFormatter(log_fmt_long) self.log_handler_file.setLevel(log_level) mdbx_logger.addHandler(self.log_handler_file) # log to journal when launched from systemd if INVOCATION_ID and journal: self.log_handler_journal = journal.JournalHandler() self.log_handler_journal.setFormatter(log_fmt_short) self.log_handler_journal.setLevel(log_level) mdbx_logger.addHandler(self.log_handler_journal) else: self.log_handler_journal = None # send systemd notifications when started as 'notify' daemon if NOTIFY_SOCKET: self.log_handler_sd = SdNotificationHandler() self.log_handler_sd.setFormatter(log_fmt_short) self.log_handler_sd.setLevel(logging.INFO) mdbx_logger.addHandler(self.log_handler_sd) else: self.log_handler_sd = None # log to stdout (disabled by default) level = log_level if self._log_to_stdout else 100 self.log_handler_stream = logging.StreamHandler(sys.stdout) self.log_handler_stream.setFormatter(log_fmt_long) self.log_handler_stream.setLevel(level) mdbx_logger.addHandler(self.log_handler_stream) # log to cached handlers for GUI and CLI self._log_handler_info_cache = CachedHandler(maxlen=1) self._log_handler_info_cache.setFormatter(log_fmt_short) self._log_handler_info_cache.setLevel(logging.INFO) mdbx_logger.addHandler(self._log_handler_info_cache) self._log_handler_error_cache = CachedHandler() self._log_handler_error_cache.setFormatter(log_fmt_short) self._log_handler_error_cache.setLevel(logging.ERROR) mdbx_logger.addHandler(self._log_handler_error_cache) # log to desktop notifications # 'file changed' events will be collated and sent as desktop # notifications by the monitor directly, we don't handle them here self.desktop_notifier = MaestralDesktopNotifier.for_config( self.config_name) self.desktop_notifier.setLevel(logging.WARNING) mdbx_logger.addHandler(self.desktop_notifier) # log to bugsnag (disabled by default) self._log_handler_bugsnag = BugsnagHandler() self._log_handler_bugsnag.setLevel(100) mdbx_logger.addHandler(self._log_handler_bugsnag) self.analytics = self._conf.get('app', 'analytics')
def test_journalhandler_init(): kw = {'X': 3, 'X3': 4} journal.JournalHandler(logging.INFO, **kw)
def test_journalhandler_init_exception(): kw = {' X ': 3} with pytest.raises(ValueError): journal.JournalHandler(**kw)
filename, str(e))) def remove_stamp_file(filename): try: os.unlink(filename) logging.info("Stamp file removed from {}".format(filename)) except OSError as e: exit_with_error("Error removing stamp file at {}: {}".format( filename, str(e))) if __name__ == '__main__': # Send logging messages both to the console and the journal logging.basicConfig(level=logging.INFO) logging.root.addHandler(journal.JournalHandler()) parser = argparse.ArgumentParser( description="Marks Google Chrome installation as installed, system-wide" ) parser.add_argument('--debug', help="Show extra messages", action='store_true') parser.add_argument('--reset', help="Remove stamp file", action='store_true') parsed_args = parser.parse_args() if parsed_args.debug: logging.root.setLevel(logging.DEBUG)