system.logging.logger.getLogger

Here are the examples of the python api system.logging.logger.getLogger taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

29 Examples 7

Example 1

Project: Ultros
Source File: factory_manager.py
View license
    def __init__(self):
        self.commands = CommandManager()
        self.event_manager = EventManager()
        self.logger = getLogger("Manager")
        self.plugman = PluginManager(self)

        self.metrics = None

Example 2

Project: Ultros
Source File: manager.py
View license
    def __init__(self):
        self.logger = getLogger("Help")
        self.add_topic(
            AliasListTopic("aliases", HelpTopicType.GenericTopic)
        )
        self.add_topic(
            ComandListTopic("commands", HelpTopicType.GenericTopic)
        )

Example 3

Project: Ultros
Source File: plugin.py
View license
    def __init__(self, info, loader):
        from system.factory_manager import FactoryManager
        from system.plugins.manager import PluginManager

        self.commands = CommandManager()
        self.events = EventManager()
        self.factory_manager = FactoryManager()
        self.info = info
        self.logger = getLogger(info.name)
        self.module = self.info.module
        self.plugins = PluginManager()
        self.storage = StorageManager()
        self._loader = loader.name

Example 4

Project: Ultros
Source File: factory.py
View license
    def __init__(self, protocol_name, config, factory_manager):
        self.name = protocol_name
        self.config = config
        self.factory_manager = factory_manager

        self.logger = getLogger("F: {}".format(self.name))

Example 5

Project: Ultros
Source File: protocol.py
View license
    def __init__(self, name, factory, config):
        # You don't necessarily need to call the super-class here,
        #   however we do recommend at least copy-pasting the below code
        #   into your __init__.
        # Twisted uses old-style classes, so super() won't work if you intend
        #   on using it!
        self.name = name
        self.factory = factory
        self.config = config
        self.log = getLogger(self.name)
        # Default values for optional main config section
        try:
            self.can_flood = self.config["main"]["can-flood"]
        except KeyError:
            self.can_flood = False

Example 6

Project: Ultros
Source File: config.py
View license
    def __init__(self, filename):
        self.callbacks = []

        self.logger = getLogger("YamlConfig")
        # Some sanitizing here to make sure people can't escape the config dirs
        filename = filename.strip("..")
        self.filename = filename
        self.exists = self.reload(False)

Example 7

Project: Ultros
Source File: config.py
View license
    def __init__(self, filename):
        self.callbacks = []

        self.logger = getLogger("YamlConfig")
        # Some sanitizing here to make sure people can't escape the config dirs
        filename = filename.strip("..")
        self.filename = filename
        self.exists = self.reload(False)

Example 8

Project: Ultros
Source File: config.py
View license
    def __init__(self, filename, data_dict):
        if filename is None:
            self.filename = ":memory:{}:".format(uuid.uuid4())
        else:
            self.filename = ":memory:{}:".format(filename)

        self.callbacks = []

        self.logger = getLogger("MemoryConfig")
        self.exists = True
        self.data = data_dict

Example 9

Project: Ultros
Source File: data.py
View license
    def __init__(self, filename):
        self.callbacks = []

        self.logger = getLogger("Data")
        filename = filename.strip("..")

        folders = filename.split("/")
        folders.pop()
        folders = "/".join(folders)

        if not os.path.exists(folders):
            os.makedirs(folders)

        self.filename = filename
        self.reload(False)

Example 10

Project: Ultros
Source File: data.py
View license
    def __init__(self, filename, data_dict):
        if filename is None:
            self.filename = ":memory:{}:".format(uuid.uuid4())
        else:
            self.filename = ":memory:{}:".format(filename)

        self.callbacks = []

        self.logger = getLogger("Data")
        self.data = data_dict

Example 11

Project: Ultros
Source File: data.py
View license
    def __init__(self, filename):
        self.callbacks = []

        self.logger = getLogger("Data")
        filename = filename.strip("..")

        folders = filename.split("/")
        folders.pop()
        folders = "/".join(folders)

        if not os.path.exists(folders):
            os.makedirs(folders)

        self.filename = filename
        self.reload(False)

Example 12

Project: Ultros
Source File: data.py
View license
    def __init__(self, path, *args, **kwargs):
        self.callbacks = []

        self.logger = getLogger("MongoDB")

        self.path = path
        self.url = kwargs.get("url", None)

        self.logger.trace("Path: %s" % path)
        self.logger.trace("Args: %s" % (args or "[]"))
        self.logger.trace("KWArgs: %s" % (kwargs or "{}"))

        self.args = args
        self.kwargs = kwargs

        self.reconnect()

Example 13

Project: Ultros
Source File: data.py
View license
    def __init__(self, path, *args, **kwargs):
        self.callbacks = []

        self.logger = getLogger("Redis")

        self.path = path
        self.url = kwargs.get("url", None)

        self.logger.trace("Path: %s" % path)
        self.logger.trace("Args: %s" % (args or "[]"))
        self.logger.trace("KWArgs: %s" % (kwargs or "{}"))

        self.args = args
        self.kwargs = kwargs

        self.reconnect()

Example 14

Project: Ultros
Source File: tokens.py
View license
    def __init__(self):
        self.token_regex = re.compile(r"\{[^}]*\}")
        self.parse_regex = re.compile(r"(?<!\\):")
        self.escape_regex = re.compile(r"\\:")

        self.logger = getLogger("Tokens")

Example 15

Project: Ultros
Source File: versions.py
View license
    def __init__(self):
        self.log = getLogger("Updates")
        self.current = current
        self.current_v = StrictVersion(current)

        self.load_release()
        self.do_warnings()

Example 16

Project: Ultros
Source File: console.py
View license
    def __init__(self):
        self.log = getLogger("GetchUnix")
        import tty
        import sys

        self.log.trace(_("Loaded: %s, %s") % (tty, sys))

Example 17

Project: Ultros
Source File: run.py
View license
def main():
    if (not args.no_upgrade) and is_virtualenv():
        update(git=False)

    if os.path.dirname(sys.argv[0]):
        os.chdir(os.path.dirname(sys.argv[0]))

    from system.logging.logger import getLogger
    from system import constants
    from system.decorators import threads

    sys.stdout = getwriter('utf-8')(sys.stdout)
    sys.stderr = getwriter('utf-8')(sys.stderr)

    ultros = Ultros(args)
    versions = VersionManager()

    if not os.path.exists("logs"):
        os.mkdir("logs")

    logger = getLogger("System")

    requests_log = logging.getLogger("requests")
    requests_log.setLevel(logging.WARNING)

    logger.info(_("Starting up, version \"%s\"") % constants.__version__)
    logger.info(constants.__version_info__)

    # Write PID to file
    fh = open("ultros.pid", "w")
    fh.write(str(os.getpid()))
    fh.flush()
    fh.close()

    logger.info(_("PID: %s") % os.getpid())

    try:
        logger.debug("Starting..")
        ultros.start()

    except Exception:
        logger.critical(_("Runtime error - process cannot continue!"))
        logger.exception("")
    except SystemExit as e:
        logger.trace("SystemExit caught!")

        logger.debug("Stopping threadpool..")
        threads.pool.stop()

        logger.debug("Removing pidfile..")
        os.remove("ultros.pid")
        exit(e.code)
    finally:
        try:
            logger.debug("Unloading manager..")
            ultros.stop()

            logger.debug("Stopping threadpool..")
            threads.pool.stop()

            logger.debug("Removing pidfile..")
            os.remove("ultros.pid")

            if args.catch:
                raw_input(_("Press enter to exit."))
        except Exception:
            pass

Example 18

Project: Ultros
Source File: manager.py
View license
    def __init__(self):
        self.logger = getLogger("Commands")
        self.event_manager = EventManager()

Example 19

Project: Ultros
Source File: core.py
View license
    def __init__(self, parsed_args):
        self.parsed_args = parsed_args
        self.factory_manager = FactoryManager()
        self.factory_manager.setup_logging(self.parsed_args)
        self.logger = getLogger("Core")

Example 20

Project: Ultros
Source File: manager.py
View license
    def __init__(self):
        self.logger = getLogger("Events")

Example 21

Project: Ultros
Source File: public.py
View license
    def __init__(self, config=None, manager=None):
        if config is None or manager is None:
            raise ValueError("Config and manager must not be None!")

        self.config = config
        self.manager = manager
        self.log = getLogger("Metrics")

        self.storage = StorageManager()
        self.events = EventManager()
        self.packages = Packages(get=False)

        self.data = self.storage.get_file(self, "data", JSON, "metrics.json")

        self.task = LoopingCall(self.submit_metrics)

        if "metrics" in config:
            self.status = config["metrics"]
            if self.status == "on":
                self.status = True
            elif self.status == "off":
                self.status = False
        else:
            self.log.warn("\n%s\n" % warning)
            self.log.warn(_(
                "We couldn't find a \"metrics\" option in your settings.yml"
                " file!"
            ))
            self.log.warn(_(
                "Metrics will default to being turned on. If this is not what"
                " you want, please create a \"metrics\" option in your "
                "settings and set it to \"off\"."
            ))
            self.log.warn(_(
                "If you want to keep metrics enabled, set the option to"
                " \"on\"."
            ))
            self.log.warn(_(
                "This warning will be shown on every startup until the option"
                " has been set."
            ))
            self.status = True

        if "send-exceptions" not in config:
            self.log.warn(_(
                "We couldn't find a \"send-exceptions\" option in your "
                "settings.yml file!"
            ))
            self.log.warn(_(
                "Exception sending will default to being turned on. If this "
                "is not what you want, please create a \"send-exceptions\" "
                "option in your settings and set it to \"off\"."
            ))
            self.log.warn(_(
                "If you want to keep exception sending enabled, set the "
                "option to \"on\"."
            ))
            self.log.warn(_(
                "This warning will be shown on every startup until the option"
                " has been set."
            ))

        self.send_exceptions = config.get("send-exceptions", True)

        with self.data:
            if self.status is True:
                if "uuid" not in self.data:
                    try:
                        uuid = self.get(self.uuid_url)
                    except Exception:
                        self.log.exception(_("Error getting UUID"))
                        return
                    self.data["uuid"] = uuid
                    self.data["status"] = "enabled"
            elif "uuid" not in self.data:
                self.data["status"] = "disabled"

        if self.status is False:
            if self.data["status"] == "disabled":
                self.log.info(_("Metrics are disabled."))
                return
        elif self.status is "destroy":
            if "uuid" not in self.data:
                self.log.info(_("Metrics are disabled."))
                return

        self.task.start(self.interval)

Example 22

Project: Ultros
Source File: base.py
View license
    def __init__(self, factory_manager, plugin_manager):
        self.logger = getLogger(self.logger_name or self.__class__.__name__)

        self.factory_manager = factory_manager
        self.plugin_manager = plugin_manager

Example 23

Project: Ultros
Source File: python.py
View license
    @inlineCallbacks
    def load_plugin(self, info):
        module = info.get_module()
        self.logger.trace("Module: {}".format(module))

        try:
            if module in sys.modules:
                self.logger.trace("Module exists, reloading..")
                reload(sys.modules[module])
                module_obj = sys.modules[module]
            else:
                module_obj = importlib.import_module(module)

            self.logger.trace("Module object: {}".format(module_obj))

            plugin_class = self.find_plugin_class(module_obj)

            if plugin_class is None:
                self.logger.error(
                    "Unable to find plugin class for plugin: {}".format(
                        info.name
                    )
                )
                returnValue((PluginState.LoadError, None))

            plugin = plugin_class(info, self)

        except ImportError:
            self.logger.exception("Unable to import plugin: {}".format(
                info.name
            ))
            returnValue((PluginState.LoadError, None))
        except Exception:
            self.logger.exception("Error loading plugin: {}".format(
                info.name
            ))
            returnValue((PluginState.LoadError, None))
        else:
            try:
                info.set_plugin_object(plugin)
                plugin.logger = getLogger(info.name)

                d = plugin.setup()

                if isinstance(d, Deferred):
                    _ = yield d
            except Exception:
                self.logger.exception("Error setting up plugin: {}".format(
                    info.name
                ))
                returnValue((PluginState.LoadError, None))
            else:
                returnValue((PluginState.Loaded, plugin))

Example 24

Project: Ultros
Source File: manager.py
View license
    def __init__(self, factory_manager=None,
                 path="./plugins", module="plugins"):
        if factory_manager is None:
            raise ValueError("Factory manager cannot be None!")

        self.log = getLogger("Plugins")
        self.loaders = {}

        python_loader = PythonPluginLoader(factory_manager, self)
        self.loaders["python"] = python_loader

        self.factory_manager = factory_manager

        self.module = module
        self.path = path

        try:
            import hy  # noqa
        except ImportError:
            hy = None  # noqa

            self.log.warn("Unable to find Hy - Hy plugins will not load")
            self.log.warn("Install Hy with pip if you need this support")

Example 25

Project: Ultros
Source File: data.py
View license
    def __init__(self, path, *args, **kwargs):
        self.callbacks = []

        self.logger = getLogger("DBAPI")

        path = path.replace("//", "/")
        path = path.split("/", 1)[1]

        self.path = path

        self.logger.trace("Path: %s" % path)
        self.logger.trace("Args: %s" % (args or "[]"))
        self.logger.trace("KWArgs: %s" % (kwargs or "{}"))

        parsed_module = path.split(":", 1)[0]
        self.parsed_module = parsed_module
        self.args = args
        self.kwargs = kwargs

        self.logger.debug(_("Parsed module: %s") % parsed_module)

        self.reconnect()

Example 26

Project: Ultros
Source File: manager.py
View license
    def __init__(self, conf_path="config/", data_path="data/"):
        self.conf_path = conf_path
        self.data_path = data_path

        self.log = getLogger("Storage")

Example 27

Project: Ultros
Source File: translations.py
View license
    def set_language(self, lang=None, mlang=None):
        if lang is None:
            lang = DEFAULT

        if mlang is None:
            mlang = DEFAULT

        self.get_known()

        if self.log and self.logger is None:
            from system.logging.logger import getLogger

            self.logger = getLogger("Translations")

        if lang not in self.known:
            if self.logger is None:
                print("Unknown language '%s', defaulting to '%s'"
                      % (lang, DEFAULT))
            else:
                self.logger.warn("Unknown language '%s', defaulting to '%s'"
                                 % (lang, DEFAULT))

            lang = DEFAULT

        if mlang not in self.known:
            if self.logger is None:
                print("Unknown language '%s', defaulting to '%s'"
                      % (mlang, DEFAULT))
            else:
                self.logger.warn("Unknown language '%s', defaulting to '%s'"
                                 % (mlang, DEFAULT))

            mlang = DEFAULT

        self.language = lang
        self.m_language = mlang
        self.reload()

Example 28

Project: Ultros
Source File: test_permissions.py
View license
    def __init__(self):
        configure(None)
        self.logger = getLogger("Permissions")

        self.confdir = tmpdir + "/config/"
        self.datadir = tmpdir + "/data/"

        try:
            os.makedirs(self.confdir)
            os.makedirs(self.datadir)
            self.logger.debug("Config and data dirs created.")
        except Exception:
            pass

        yaml.dump({"editor_warning": False},
                  open(self.confdir + "settings.yml", "w"))

        self.storage = StorageManager(self.confdir, self.datadir)

        self.data = self.storage.get_file(self, "data", formats.YAML,
                                          "permissions.yml")

        self.handler = permissionsHandler(self, self.data)

        super(TestPlugin, self).__init__(
            AttrDict(name="test", module="test_permissions"),
            AttrDict(name="python"),
        )

Example 29

Project: Ultros
Source File: console.py
View license
    def __init__(self):
        self.log = getLogger("GetchWindows")
        import msvcrt

        self.log.trace(_("Loaded: %s") % msvcrt)