{"action":"closed","issue":{"url":"https://api.github.com/repos/hynek/structlog/issues/184","repository_url":"https://api.github.com/repos/hynek/structlog","labels_url":"https://api.github.com/repos/hynek/structlog/issues/184/labels{/name}","comments_url":"https://api.github.com/repos/hynek/structlog/issues/184/comments","events_url":"https://api.github.com/repos/hynek/structlog/issues/184/events","html_url":"https://github.com/hynek/structlog/issues/184","id":373211626,"node_id":"MDU6SXNzdWUzNzMyMTE2MjY=","number":184,"title":"question: help on using structlog and dictConfig ","user":{"login":"nskalis","id":8971544,"node_id":"MDQ6VXNlcjg5NzE1NDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/8971544?v=4","gravatar_id":"","url":"https://api.github.com/users/nskalis","html_url":"https://github.com/nskalis","followers_url":"https://api.github.com/users/nskalis/followers","following_url":"https://api.github.com/users/nskalis/following{/other_user}","gists_url":"https://api.github.com/users/nskalis/gists{/gist_id}","starred_url":"https://api.github.com/users/nskalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nskalis/subscriptions","organizations_url":"https://api.github.com/users/nskalis/orgs","repos_url":"https://api.github.com/users/nskalis/repos","events_url":"https://api.github.com/users/nskalis/events{/privacy}","received_events_url":"https://api.github.com/users/nskalis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-23T21:33:39Z","updated_at":"2018-10-24T07:58:14Z","closed_at":"2018-10-24T07:58:14Z","author_association":"NONE","body":"hi,\r\n\r\ni am trying to use `structlog` according to the docs, but i fail to make it working:\r\n\r\n* **catalog.py**\r\n```python\r\nimport os\r\nimport yaml\r\nimport logging.config\r\nimport structlog\r\nwith open(\r\n    \"{}/ip-spotlight/config/{}\".format(\r\n        os.environ[\"DIR_BASE\"], \"logger.api.catalog.yaml\"\r\n    ),\r\n    \"rt\",\r\n) as f:\r\n    logging.config.dictConfig(yaml.safe_load(f.read()))\r\nstructlog.configure(\r\n    processors=[\r\n        structlog.stdlib.filter_by_level,\r\n        structlog.stdlib.add_logger_name,\r\n        structlog.stdlib.add_log_level,\r\n        structlog.stdlib.PositionalArgumentsFormatter(),\r\n        structlog.processors.StackInfoRenderer(),\r\n        structlog.processors.format_exc_info,\r\n        structlog.processors.UnicodeDecoder(),\r\n        structlog.stdlib.render_to_log_kwargs,\r\n    ],\r\n    context_class=dict,\r\n    logger_factory=structlog.stdlib.LoggerFactory(),\r\n    wrapper_class=structlog.stdlib.BoundLogger,\r\n    cache_logger_on_first_use=True,\r\n)\r\nlogger = structlog.get_logger(\"catalog\")\r\n\r\nimport responder\r\nimport schemas\r\nimport auth\r\n...\r\n```\r\n\r\n* **logger.api.catalog.yaml**\r\n```yaml\r\n---\r\n\r\n\r\n  version: 1\r\n  disable_existing_loggers: False\r\n\r\n\r\n  formatters:\r\n\r\n    simple:\r\n      format: '%(asctime)s | %(levelname)s | %(process)d | %(module)s | %(funcName)s | %(message)s'\r\n\r\n\r\n  handlers:\r\n\r\n    console:\r\n      class: logging.StreamHandler\r\n      level: INFO\r\n      formatter: simple\r\n      stream: ext://sys.stdout\r\n\r\n    logfile:\r\n      class: logging.FileHandler\r\n      level: INFO\r\n      formatter: simple\r\n      encoding: utf8\r\n      filename: /var/log/ip-spotlight/ip-spotlight.api.catalog.log\r\n\r\n\r\n  loggers:\r\n\r\n    catalog:\r\n      propagate: no\r\n      level: INFO\r\n      handlers:\r\n        - logfile\r\n\r\n\r\n  root:\r\n    level: WARNING\r\n    handlers:\r\n      - logfile\r\n```\r\n\r\n* **auth.py**\r\n```python\r\nimport structlog\r\nlogger = structlog.get_logger(\"catalog\")\r\n\r\ndef uim(username, password, application):\r\n...\r\n    logger.info(\"assigning ldap roles\", username=\"username\")#, roles=roles)\r\n    return roles\r\n```\r\n\r\nthe log produced is\r\n```\r\n2018-10-23 23:26:40,915 | INFO | 30051 | _base | _proxy_to_logger | assigning ldap roles\r\n```\r\n\r\ncould you please advise what i am doing wrong ?"}}
{"actor":{"display_login":"nskalis"}}