def start(self): # Initialize data store DatastoreController().set_driver(self.config.get('datastore')) Logger.set_loglevel(self.config.get('log.level')) for plugin in self.config.get('coreplugins'): Logger.info("Loading core plugin '%s'" % plugin) self.plugincontroller.load_plugin(plugin, 'core') for plugin in self.config.get('plugins'): Logger.info("Loading plugin '%s'" % plugin) self.plugincontroller.load_plugin(plugin) if len(self.config.get('ircnets')) == 0: raise Exception("There has to be at least one ircnet to connect to") for net in self.config.get('ircnets'): irc = IRCController(self.eventcontroller) irc.set_configuration(net) Logger.info("Connecting to %s..." % irc.get_ircnet_name()) irc.connect() self.ircnetscontroller.add_ircnet(irc.get_ircnet_name(), irc)
def cmd_debug(self, irc, params): """ Enable or disable debugging debug [1|2|3|off] """ if len(params) == 0: irc.reply("Not enough parameters") return if params[0] == 'off': Logger.set_loglevel('FATAL') irc.reply("Debugging disabled") elif int(params[0]) in [1, 2, 3]: num_level = int(params[0]) level = ["DEBUGL1", "DEBUGL2", "DEBUGL3"][num_level - 1] Logger.set_loglevel(level) irc.reply("Debugging enabled at level %d" % num_level) else: irc.reply("Invalid option")
def get_loaded_plugins(): result = {} for name in PluginController().get_loaded_plugins(): result[name] = None return result parser = OptionParser() parser.add_option("-p", "--plugins", dest="plugins", help="List of plugins to load separated by commas") parser.add_option("-d", "--debug", default=False, action="store_true", dest="debug", help="Enable debug log") (options, args) = parser.parse_args() if options.debug: Logger.set_loglevel("DEBUGL2") sim = Simulator() sim.load_plugin("corecommands", "core") sim.load_plugin("aclcommands", "core") if options.plugins: plugins = options.plugins.split(",") for plugin in plugins: Logger.info("Loading %s" % plugin) try: sim.load_plugin(plugin) except Exception as e: Logger.log_traceback(sim)
from lib.logger import Logger Logger.set_loglevel('FATAL')