def load_units(self):
        """
        Build a set of systemd units that Ellis will watch.

        This set will be used to filter journald entries so that we only
        process entries that were produced by these units.
        This should result in better performance.
        """
        # Of course, we only consider valid Rules.
        for rule in self.rules:
            try:
                systemd_unit = self.config.get(rule.name, 'systemd_unit')

            except configparser.NoOptionError:
                warnings.warn("Rule '{0}' doesn't have a `systemd_unit` "
                              "option set.\nThe filters will be checked "
                              "against all journald entries, which will "
                              "probably result in poor performance."
                              .format(rule.name))

                # At this point,  we can clear `self.units` because in any
                # case, we will need to process every journald entries
                # for THIS Rule.
                self.units.clear()

                # And we can also stop looping through rules.
                break

            else:
                # Append ".service" if not present.
                # Note that we don't check if the service actually exists.
                # FIXME ?
                if not systemd_unit.endswith(".service"):
                    systemd_unit += ".service"

                self.units.add(systemd_unit)

        return self
def load_units ( self ) : for rule in self . rules : try : systemd_unit = self . config . get ( rule . name , 'systemd_unit' ) except configparser . NoOptionError : warnings . warn ( "Rule '{0}' doesn't have a `systemd_unit` " "option set.\nThe filters will be checked " "against all journald entries, which will " "probably result in poor performance." . format ( rule . name ) ) self . units . clear ( ) break else : if not systemd_unit . endswith ( ".service" ) : systemd_unit += ".service" self . units . add ( systemd_unit ) return self
Build a set of systemd units that Ellis will watch.

        This set will be used to filter journald entries so that we only
        process entries that were produced by these units.
        This should result in better performance.