{"action":"created","issue":{"url":"https://api.github.com/repos/crossbario/txaio/issues/75","repository_url":"https://api.github.com/repos/crossbario/txaio","labels_url":"https://api.github.com/repos/crossbario/txaio/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/crossbario/txaio/issues/75/comments","events_url":"https://api.github.com/repos/crossbario/txaio/issues/75/events","html_url":"https://github.com/crossbario/txaio/issues/75","id":152862607,"number":75,"title":"txaio std lib logging","user":{"login":"singlecheeze","id":12156213,"avatar_url":"https://avatars.githubusercontent.com/u/12156213?v=3","gravatar_id":"","url":"https://api.github.com/users/singlecheeze","html_url":"https://github.com/singlecheeze","followers_url":"https://api.github.com/users/singlecheeze/followers","following_url":"https://api.github.com/users/singlecheeze/following{/other_user}","gists_url":"https://api.github.com/users/singlecheeze/gists{/gist_id}","starred_url":"https://api.github.com/users/singlecheeze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singlecheeze/subscriptions","organizations_url":"https://api.github.com/users/singlecheeze/orgs","repos_url":"https://api.github.com/users/singlecheeze/repos","events_url":"https://api.github.com/users/singlecheeze/events{/privacy}","received_events_url":"https://api.github.com/users/singlecheeze/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-03T20:06:45Z","updated_at":"2016-05-03T20:14:52Z","closed_at":null,"body":"Please see https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/autobahnws/vxb4e03IUOQ\r\n``` python\r\n# Name would allow for _TxaioLogWrapper to not call std lib logging.getLogger with no name thus defaulting to root logging instance \r\ndef make_logger(name=None):\r\n    logger = _TxaioLogWrapper(logging.getLogger(name))\r\n    # remember this so we can set their levels properly once\r\n    # start_logging is actually called\r\n    _loggers.add(logger)\r\n    return logger\r\n\r\n\r\ndef start_logging(name=None, out=_stdout, level='info'):\r\n    \"\"\"\r\n    Begin logging.\r\n\r\n    :param out: if provided, a file-like object to log to. By default, this is\r\n                stdout.\r\n    :param level: the maximum log-level to emit (a string)\r\n    \"\"\"\r\n    global _log_level, _loggers, _started_logging     ****** I tried setting log level to \"none\" and that passes this test but isn't implemented and throws another error\r\n    if level not in log_levels:\r\n        raise RuntimeError(\r\n            \"Invalid log level '{0}'; valid are: {1}\".format(\r\n                level, ', '.join(log_levels)\r\n            )\r\n        )\r\n\r\n    if _started_logging:\r\n        return\r\n\r\n    _started_logging = True\r\n    _log_level = level\r\n\r\n    handler = _TxaioFileHandler(out)\r\n    logging.getLogger(name).addHandler(handler)   ****** Name here too so that root logger isn't used\r\n    # note: Don't need to call basicConfig() or similar, because we've\r\n    # now added at least one handler to the root logger\r\n    logging.raiseExceptions = True  # FIXME\r\n    level_to_stdlib = {\r\n        'critical': logging.CRITICAL,\r\n        'error': logging.ERROR,\r\n        'warn': logging.WARNING,\r\n        'info': logging.INFO,\r\n        'debug': logging.DEBUG,\r\n        'trace': logging.DEBUG,\r\n    }\r\n    logging.getLogger(name).setLevel(level_to_stdlib[level])   ****** Name here too so that root logger isn't used\r\n    # make sure any loggers we created before now have their log-level\r\n    # set (any created after now will get it from _log_level\r\n    for logger in _loggers:\r\n        logger._set_log_level(level)\r\n```"},"comment":{"url":"https://api.github.com/repos/crossbario/txaio/issues/comments/216651341","html_url":"https://github.com/crossbario/txaio/issues/75#issuecomment-216651341","issue_url":"https://api.github.com/repos/crossbario/txaio/issues/75","id":216651341,"user":{"login":"singlecheeze","id":12156213,"avatar_url":"https://avatars.githubusercontent.com/u/12156213?v=3","gravatar_id":"","url":"https://api.github.com/users/singlecheeze","html_url":"https://github.com/singlecheeze","followers_url":"https://api.github.com/users/singlecheeze/followers","following_url":"https://api.github.com/users/singlecheeze/following{/other_user}","gists_url":"https://api.github.com/users/singlecheeze/gists{/gist_id}","starred_url":"https://api.github.com/users/singlecheeze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singlecheeze/subscriptions","organizations_url":"https://api.github.com/users/singlecheeze/orgs","repos_url":"https://api.github.com/users/singlecheeze/repos","events_url":"https://api.github.com/users/singlecheeze/events{/privacy}","received_events_url":"https://api.github.com/users/singlecheeze/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T20:14:52Z","updated_at":"2016-05-03T20:14:52Z","body":"Also this:\r\n``` text\r\nTraceback (most recent call last):\r\n  File \"/home/dave/PycharmProjects/monocle/backend/backend.py\", line 1716, in <module>\r\n    txaio.start_logging(level='none')\r\n  File \"/usr/lib/python3.5/site-packages/txaio/aio.py\", line 222, in start_logging\r\n    logging.getLogger().setLevel(level_to_stdlib[level])\r\nKeyError: 'none'\r\n```\r\n\r\nThe first check passes but lookup dict for std lib logging does not include the \"none\" log level:\r\n``` python\r\ndef start_logging(out=_stdout, level='info'):\r\n    \"\"\"\r\n    Begin logging.\r\n\r\n    :param out: if provided, a file-like object to log to. By default, this is\r\n                stdout.\r\n    :param level: the maximum log-level to emit (a string)\r\n    \"\"\"\r\n    global _log_level, _loggers, _started_logging\r\n    if level not in log_levels:\r\n        raise RuntimeError(\r\n            \"Invalid log level '{0}'; valid are: {1}\".format(\r\n                level, ', '.join(log_levels)\r\n            )\r\n        )\r\n```"}}