We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug: logging queue listener writing to in-memory stream
The handler for the `queue_listener` handler is created as `StreamHandler(StringIO())`. Explicitly passing the stream to the the handler means that the output is no longer logged to stderr.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `starlite/logging/standard.py`
Content:
```
1 import atexit
2 from io import StringIO
3 from logging import StreamHandler
4 from logging.handlers import QueueHandler, QueueListener
5 from queue import Queue
6 from typing import Any, List, Optional
7 
8 from starlite.logging.utils import resolve_handlers
9 
10 
11 class QueueListenerHandler(QueueHandler):
12     def __init__(self, handlers: Optional[List[Any]] = None) -> None:
13         """Configures queue listener and handler to support non-blocking
14         logging configuration.
15 
16         Args:
17             handlers: Optional 'ConvertingList'
18         """
19         super().__init__(Queue(-1))
20         if handlers:
21             handlers = resolve_handlers(handlers)
22         else:
23             handlers = [StreamHandler(StringIO())]
24         self.listener = QueueListener(self.queue, *handlers)
25         self.listener.start()
26 
27         atexit.register(self.listener.stop)
28
```

Path: `starlite/logging/picologging.py`
Content:
```
1 import atexit
2 from io import StringIO
3 from logging import StreamHandler
4 from queue import Queue
5 from typing import Any, List, Optional
6 
7 from starlite.exceptions import MissingDependencyException
8 from starlite.logging.utils import resolve_handlers
9 
10 try:
11     from picologging.handlers import QueueHandler, QueueListener
12 except ImportError as e:
13     raise MissingDependencyException("picologging is not installed") from e
14 
15 
16 class QueueListenerHandler(QueueHandler):  # type: ignore[misc]
17     def __init__(self, handlers: Optional[List[Any]] = None) -> None:
18         """Configures queue listener and handler to support non-blocking
19         logging configuration.
20 
21         Args:
22             handlers: Optional 'ConvertingList'
23 
24         Notes:
25             - Requires `picologging` to be installed.
26         """
27         super().__init__(Queue(-1))
28         if handlers:
29             handlers = resolve_handlers(handlers)
30         else:
31             handlers = [StreamHandler(StringIO())]
32         self.listener = QueueListener(self.queue, *handlers)
33         self.listener.start()
34 
35         atexit.register(self.listener.stop)
36
```

Path: `starlite/config/logging.py`
Content:
```
1 from abc import ABC, abstractmethod
2 from importlib.util import find_spec
3 from logging import INFO
4 from typing import (
5     TYPE_CHECKING,
6     Any,
7     Callable,
8     Dict,
9     Iterable,
10     List,
11     Optional,
12     Type,
13     Union,
14     cast,
15 )
16 
17 from orjson import dumps
18 from pydantic import BaseModel, Field, validator
19 from typing_extensions import Literal
20 
21 from starlite.exceptions import (
22     ImproperlyConfiguredException,
23     MissingDependencyException,
24 )
25 
26 if TYPE_CHECKING:
27     from starlite.types import Logger
28     from starlite.types.callable_types import GetLogger
29 
30 try:
31     from structlog.types import BindableLogger, Processor, WrappedLogger
32 except ImportError:
33     BindableLogger = Any  # type: ignore
34     Processor = Any  # type: ignore
35     WrappedLogger = Any  # type: ignore
36 
37 
38 default_handlers: Dict[str, Dict[str, Any]] = {
39     "console": {
40         "class": "logging.StreamHandler",
41         "level": "DEBUG",
42         "formatter": "standard",
43     },
44     "queue_listener": {
45         "class": "starlite.logging.standard.QueueListenerHandler",
46         "level": "DEBUG",
47         "formatter": "standard",
48     },
49 }
50 
51 default_picologging_handlers: Dict[str, Dict[str, Any]] = {
52     "console": {
53         "class": "picologging.StreamHandler",
54         "level": "DEBUG",
55         "formatter": "standard",
56     },
57     "queue_listener": {
58         "class": "starlite.logging.picologging.QueueListenerHandler",
59         "level": "DEBUG",
60         "formatter": "standard",
61     },
62 }
63 
64 
65 def get_default_handlers() -> Dict[str, Dict[str, Any]]:
66     """
67 
68     Returns:
69         The default handlers for the config.
70     """
71     if find_spec("picologging"):
72         return default_picologging_handlers
73     return default_handlers
74 
75 
76 def get_logger_placeholder(_: str) -> Any:  # pragma: no cover
77     """
78     Raises:
79         ImproperlyConfiguredException
80     """
81     raise ImproperlyConfiguredException(
82         "To use 'app.get_logger', 'request.get_logger' or 'socket.get_logger' pass 'logging_config' to the Starlite constructor"
83     )
84 
85 
86 class BaseLoggingConfig(ABC):  # pragma: no cover
87     """Abstract class that should be extended by logging configs."""
88 
89     __slots__ = ()
90 
91     @abstractmethod
92     def configure(self) -> "GetLogger":
93         """Configured logger with the given configuration.
94 
95         Returns:
96             A 'logging.getLogger' like function.
97         """
98         raise NotImplementedError("abstract method")
99 
100 
101 class LoggingConfig(BaseLoggingConfig, BaseModel):
102     """Configuration class for standard logging.
103 
104     Notes:
105         - If 'picologging' is installed it will be used by default.
106     """
107 
108     version: Literal[1] = 1
109     """The only valid value at present is 1."""
110     incremental: bool = False
111     """Whether the configuration is to be interpreted as incremental to the existing configuration.
112 
113     Notes:
114         - This option is ignored for 'picologging'
115     """
116     disable_existing_loggers: bool = False
117     """Whether any existing non-root loggers are to be disabled."""
118     filters: Optional[Dict[str, Dict[str, Any]]] = None
119     """A dict in which each key is a filter id and each value is a dict describing how to configure the corresponding Filter instance."""
120     propagate: bool = True
121     """If messages must propagate to handlers higher up the logger hierarchy from this logger."""
122     formatters: Dict[str, Dict[str, Any]] = {
123         "standard": {"format": "%(levelname)s - %(asctime)s - %(name)s - %(module)s - %(message)s"}
124     }
125     handlers: Dict[str, Dict[str, Any]] = Field(default_factory=get_default_handlers)
126     """A dict in which each key is a handler id and each value is a dict describing how to configure the corresponding Handler instance."""
127     loggers: Dict[str, Dict[str, Any]] = {
128         "starlite": {
129             "level": "INFO",
130             "handlers": ["queue_listener"],
131         },
132     }
133     """A dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance."""
134     root: Dict[str, Union[Dict[str, Any], List[Any], str]] = {
135         "handlers": ["queue_listener", "console"],
136         "level": "INFO",
137     }
138     """This will be the configuration for the root logger. Processing of the configuration will be as for any logger,
139     except that the propagate setting will not be applicable."""
140 
141     @validator("handlers", always=True)
142     def validate_handlers(  # pylint: disable=no-self-argument
143         cls, value: Dict[str, Dict[str, Any]]
144     ) -> Dict[str, Dict[str, Any]]:
145         """
146         Ensures that 'queue_listener' is always set
147         Args:
148             value: A dict of route handlers.
149 
150         Returns:
151             A dict of route handlers.
152         """
153         if "queue_listener" not in value:
154             value["queue_listener"] = get_default_handlers()["queue_listener"]
155         return value
156 
157     @validator("loggers", always=True)
158     def validate_loggers(  # pylint: disable=no-self-argument
159         cls, value: Dict[str, Dict[str, Any]]
160     ) -> Dict[str, Dict[str, Any]]:
161         """Ensures that the 'starlite' logger is always set.
162 
163         Args:
164             value: A dict of loggers.
165 
166         Returns:
167             A dict of loggers.
168         """
169 
170         if "starlite" not in value:
171             value["starlite"] = {
172                 "level": "INFO",
173                 "handlers": ["queue_listener"],
174             }
175         return value
176 
177     def configure(self) -> "GetLogger":
178         """Configured logger with the given configuration.
179 
180         Returns:
181             A 'logging.getLogger' like function.
182         """
183         try:
184             if "picologging" in str(dumps(self.handlers)):
185 
186                 from picologging import (  # pylint: disable=import-outside-toplevel
187                     config,
188                     getLogger,
189                 )
190 
191                 values = self.dict(exclude_none=True, exclude={"incremental"})
192             else:
193                 from logging import (  # type: ignore[no-redef]  # pylint: disable=import-outside-toplevel
194                     config,
195                     getLogger,
196                 )
197 
198                 values = self.dict(exclude_none=True)
199             config.dictConfig(values)
200             return cast("Callable[[str], Logger]", getLogger)
201         except ImportError as e:  # pragma: no cover
202             raise MissingDependencyException("picologging is not installed") from e
203 
204 
205 def default_structlog_processors() -> Optional[Iterable[Processor]]:  # pyright: ignore
206     """Sets the default processors for structlog.
207 
208     Returns:
209         An optional list of processors.
210     """
211     try:
212         import structlog  # pylint: disable=import-outside-toplevel
213 
214         return [
215             structlog.contextvars.merge_contextvars,
216             structlog.processors.add_log_level,
217             structlog.processors.format_exc_info,
218             structlog.processors.TimeStamper(fmt="iso", utc=True),
219             structlog.processors.JSONRenderer(serializer=dumps),
220         ]
221     except ImportError:  # pragma: no cover
222         return None
223 
224 
225 def default_wrapper_class() -> Optional[Type[BindableLogger]]:  # pyright: ignore
226     """Sets the default wrapper class for structlog.
227 
228     Returns:
229         An optional wrapper class.
230     """
231 
232     try:
233         import structlog  # pylint: disable=import-outside-toplevel
234 
235         return structlog.make_filtering_bound_logger(INFO)
236     except ImportError:  # pragma: no cover
237         return None
238 
239 
240 def default_logger_factory() -> Optional[Callable[..., WrappedLogger]]:
241     """Sets the default logger factory for structlog.
242 
243     Returns:
244         An optional logger factory.
245     """
246     try:
247         import structlog  # pylint: disable=import-outside-toplevel
248 
249         return structlog.BytesLoggerFactory()
250     except ImportError:  # pragma: no cover
251         return None
252 
253 
254 class StructLoggingConfig(BaseLoggingConfig, BaseModel):
255     """Configuration class for structlog.
256 
257     Notes:
258         - requires 'structlog' to be installed.
259     """
260 
261     processors: Optional[Iterable[Processor]] = Field(default_factory=default_structlog_processors)  # pyright: ignore
262     """Iterable of structlog logging processors."""
263     wrapper_class: Optional[Type[BindableLogger]] = Field(default_factory=default_wrapper_class)  # pyright: ignore
264     """Structlog bindable logger."""
265     context_class: Optional[Dict[str, Any]] = None
266     """Context class (a 'contextvar' context) for the logger"""
267     logger_factory: Optional[Callable[..., WrappedLogger]] = Field(default_factory=default_logger_factory)
268     """Logger factory to use."""
269     cache_logger_on_first_use: bool = True
270     """Whether to cache the logger configuration and reuse. """
271 
272     def configure(self) -> "GetLogger":
273         """Configured logger with the given configuration.
274 
275         Returns:
276             A 'logging.getLogger' like function.
277         """
278         try:
279             from structlog import (  # pylint: disable=import-outside-toplevel
280                 configure,
281                 get_logger,
282             )
283 
284             # we now configure structlog
285             configure(**self.dict(exclude={"standard_lib_logging_config"}))
286             return get_logger
287         except ImportError as e:  # pragma: no cover
288             raise MissingDependencyException("structlog is not installed") from e
289
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/starlite/config/logging.py b/starlite/config/logging.py
--- a/starlite/config/logging.py
+++ b/starlite/config/logging.py
@@ -132,7 +132,7 @@
     }
     """A dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance."""
     root: Dict[str, Union[Dict[str, Any], List[Any], str]] = {
-        "handlers": ["queue_listener", "console"],
+        "handlers": ["queue_listener"],
         "level": "INFO",
     }
     """This will be the configuration for the root logger. Processing of the configuration will be as for any logger,
diff --git a/starlite/logging/picologging.py b/starlite/logging/picologging.py
--- a/starlite/logging/picologging.py
+++ b/starlite/logging/picologging.py
@@ -1,5 +1,4 @@
 import atexit
-from io import StringIO
 from logging import StreamHandler
 from queue import Queue
 from typing import Any, List, Optional
@@ -28,7 +27,7 @@
         if handlers:
             handlers = resolve_handlers(handlers)
         else:
-            handlers = [StreamHandler(StringIO())]
+            handlers = [StreamHandler()]
         self.listener = QueueListener(self.queue, *handlers)
         self.listener.start()
 
diff --git a/starlite/logging/standard.py b/starlite/logging/standard.py
--- a/starlite/logging/standard.py
+++ b/starlite/logging/standard.py
@@ -1,5 +1,4 @@
 import atexit
-from io import StringIO
 from logging import StreamHandler
 from logging.handlers import QueueHandler, QueueListener
 from queue import Queue
@@ -20,7 +19,7 @@
         if handlers:
             handlers = resolve_handlers(handlers)
         else:
-            handlers = [StreamHandler(StringIO())]
+            handlers = [StreamHandler()]
         self.listener = QueueListener(self.queue, *handlers)
         self.listener.start()

{"golden_diff": "diff --git a/starlite/config/logging.py b/starlite/config/logging.py\n--- a/starlite/config/logging.py\n+++ b/starlite/config/logging.py\n@@ -132,7 +132,7 @@\n     }\n     \"\"\"A dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance.\"\"\"\n     root: Dict[str, Union[Dict[str, Any], List[Any], str]] = {\n-        \"handlers\": [\"queue_listener\", \"console\"],\n+        \"handlers\": [\"queue_listener\"],\n         \"level\": \"INFO\",\n     }\n     \"\"\"This will be the configuration for the root logger. Processing of the configuration will be as for any logger,\ndiff --git a/starlite/logging/picologging.py b/starlite/logging/picologging.py\n--- a/starlite/logging/picologging.py\n+++ b/starlite/logging/picologging.py\n@@ -1,5 +1,4 @@\n import atexit\n-from io import StringIO\n from logging import StreamHandler\n from queue import Queue\n from typing import Any, List, Optional\n@@ -28,7 +27,7 @@\n         if handlers:\n             handlers = resolve_handlers(handlers)\n         else:\n-            handlers = [StreamHandler(StringIO())]\n+            handlers = [StreamHandler()]\n         self.listener = QueueListener(self.queue, *handlers)\n         self.listener.start()\n \ndiff --git a/starlite/logging/standard.py b/starlite/logging/standard.py\n--- a/starlite/logging/standard.py\n+++ b/starlite/logging/standard.py\n@@ -1,5 +1,4 @@\n import atexit\n-from io import StringIO\n from logging import StreamHandler\n from logging.handlers import QueueHandler, QueueListener\n from queue import Queue\n@@ -20,7 +19,7 @@\n         if handlers:\n             handlers = resolve_handlers(handlers)\n         else:\n-            handlers = [StreamHandler(StringIO())]\n+            handlers = [StreamHandler()]\n         self.listener = QueueListener(self.queue, *handlers)\n         self.listener.start()\n", "issue": "Bug: logging queue listener writing to in-memory stream\nThe handler for the `queue_listener` handler is created as `StreamHandler(StringIO())`. Explicitly passing the stream to the the handler means that the output is no longer logged to stderr.\r\n\n", "before_files": [{"content": "import atexit\nfrom io import StringIO\nfrom logging import StreamHandler\nfrom logging.handlers import QueueHandler, QueueListener\nfrom queue import Queue\nfrom typing import Any, List, Optional\n\nfrom starlite.logging.utils import resolve_handlers\n\n\nclass QueueListenerHandler(QueueHandler):\n    def __init__(self, handlers: Optional[List[Any]] = None) -> None:\n        \"\"\"Configures queue listener and handler to support non-blocking\n        logging configuration.\n\n        Args:\n            handlers: Optional 'ConvertingList'\n        \"\"\"\n        super().__init__(Queue(-1))\n        if handlers:\n            handlers = resolve_handlers(handlers)\n        else:\n            handlers = [StreamHandler(StringIO())]\n        self.listener = QueueListener(self.queue, *handlers)\n        self.listener.start()\n\n        atexit.register(self.listener.stop)\n", "path": "starlite/logging/standard.py"}, {"content": "import atexit\nfrom io import StringIO\nfrom logging import StreamHandler\nfrom queue import Queue\nfrom typing import Any, List, Optional\n\nfrom starlite.exceptions import MissingDependencyException\nfrom starlite.logging.utils import resolve_handlers\n\ntry:\n    from picologging.handlers import QueueHandler, QueueListener\nexcept ImportError as e:\n    raise MissingDependencyException(\"picologging is not installed\") from e\n\n\nclass QueueListenerHandler(QueueHandler):  # type: ignore[misc]\n    def __init__(self, handlers: Optional[List[Any]] = None) -> None:\n        \"\"\"Configures queue listener and handler to support non-blocking\n        logging configuration.\n\n        Args:\n            handlers: Optional 'ConvertingList'\n\n        Notes:\n            - Requires `picologging` to be installed.\n        \"\"\"\n        super().__init__(Queue(-1))\n        if handlers:\n            handlers = resolve_handlers(handlers)\n        else:\n            handlers = [StreamHandler(StringIO())]\n        self.listener = QueueListener(self.queue, *handlers)\n        self.listener.start()\n\n        atexit.register(self.listener.stop)\n", "path": "starlite/logging/picologging.py"}, {"content": "from abc import ABC, abstractmethod\nfrom importlib.util import find_spec\nfrom logging import INFO\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Dict,\n    Iterable,\n    List,\n    Optional,\n    Type,\n    Union,\n    cast,\n)\n\nfrom orjson import dumps\nfrom pydantic import BaseModel, Field, validator\nfrom typing_extensions import Literal\n\nfrom starlite.exceptions import (\n    ImproperlyConfiguredException,\n    MissingDependencyException,\n)\n\nif TYPE_CHECKING:\n    from starlite.types import Logger\n    from starlite.types.callable_types import GetLogger\n\ntry:\n    from structlog.types import BindableLogger, Processor, WrappedLogger\nexcept ImportError:\n    BindableLogger = Any  # type: ignore\n    Processor = Any  # type: ignore\n    WrappedLogger = Any  # type: ignore\n\n\ndefault_handlers: Dict[str, Dict[str, Any]] = {\n    \"console\": {\n        \"class\": \"logging.StreamHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n    \"queue_listener\": {\n        \"class\": \"starlite.logging.standard.QueueListenerHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n}\n\ndefault_picologging_handlers: Dict[str, Dict[str, Any]] = {\n    \"console\": {\n        \"class\": \"picologging.StreamHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n    \"queue_listener\": {\n        \"class\": \"starlite.logging.picologging.QueueListenerHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n}\n\n\ndef get_default_handlers() -> Dict[str, Dict[str, Any]]:\n    \"\"\"\n\n    Returns:\n        The default handlers for the config.\n    \"\"\"\n    if find_spec(\"picologging\"):\n        return default_picologging_handlers\n    return default_handlers\n\n\ndef get_logger_placeholder(_: str) -> Any:  # pragma: no cover\n    \"\"\"\n    Raises:\n        ImproperlyConfiguredException\n    \"\"\"\n    raise ImproperlyConfiguredException(\n        \"To use 'app.get_logger', 'request.get_logger' or 'socket.get_logger' pass 'logging_config' to the Starlite constructor\"\n    )\n\n\nclass BaseLoggingConfig(ABC):  # pragma: no cover\n    \"\"\"Abstract class that should be extended by logging configs.\"\"\"\n\n    __slots__ = ()\n\n    @abstractmethod\n    def configure(self) -> \"GetLogger\":\n        \"\"\"Configured logger with the given configuration.\n\n        Returns:\n            A 'logging.getLogger' like function.\n        \"\"\"\n        raise NotImplementedError(\"abstract method\")\n\n\nclass LoggingConfig(BaseLoggingConfig, BaseModel):\n    \"\"\"Configuration class for standard logging.\n\n    Notes:\n        - If 'picologging' is installed it will be used by default.\n    \"\"\"\n\n    version: Literal[1] = 1\n    \"\"\"The only valid value at present is 1.\"\"\"\n    incremental: bool = False\n    \"\"\"Whether the configuration is to be interpreted as incremental to the existing configuration.\n\n    Notes:\n        - This option is ignored for 'picologging'\n    \"\"\"\n    disable_existing_loggers: bool = False\n    \"\"\"Whether any existing non-root loggers are to be disabled.\"\"\"\n    filters: Optional[Dict[str, Dict[str, Any]]] = None\n    \"\"\"A dict in which each key is a filter id and each value is a dict describing how to configure the corresponding Filter instance.\"\"\"\n    propagate: bool = True\n    \"\"\"If messages must propagate to handlers higher up the logger hierarchy from this logger.\"\"\"\n    formatters: Dict[str, Dict[str, Any]] = {\n        \"standard\": {\"format\": \"%(levelname)s - %(asctime)s - %(name)s - %(module)s - %(message)s\"}\n    }\n    handlers: Dict[str, Dict[str, Any]] = Field(default_factory=get_default_handlers)\n    \"\"\"A dict in which each key is a handler id and each value is a dict describing how to configure the corresponding Handler instance.\"\"\"\n    loggers: Dict[str, Dict[str, Any]] = {\n        \"starlite\": {\n            \"level\": \"INFO\",\n            \"handlers\": [\"queue_listener\"],\n        },\n    }\n    \"\"\"A dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance.\"\"\"\n    root: Dict[str, Union[Dict[str, Any], List[Any], str]] = {\n        \"handlers\": [\"queue_listener\", \"console\"],\n        \"level\": \"INFO\",\n    }\n    \"\"\"This will be the configuration for the root logger. Processing of the configuration will be as for any logger,\n    except that the propagate setting will not be applicable.\"\"\"\n\n    @validator(\"handlers\", always=True)\n    def validate_handlers(  # pylint: disable=no-self-argument\n        cls, value: Dict[str, Dict[str, Any]]\n    ) -> Dict[str, Dict[str, Any]]:\n        \"\"\"\n        Ensures that 'queue_listener' is always set\n        Args:\n            value: A dict of route handlers.\n\n        Returns:\n            A dict of route handlers.\n        \"\"\"\n        if \"queue_listener\" not in value:\n            value[\"queue_listener\"] = get_default_handlers()[\"queue_listener\"]\n        return value\n\n    @validator(\"loggers\", always=True)\n    def validate_loggers(  # pylint: disable=no-self-argument\n        cls, value: Dict[str, Dict[str, Any]]\n    ) -> Dict[str, Dict[str, Any]]:\n        \"\"\"Ensures that the 'starlite' logger is always set.\n\n        Args:\n            value: A dict of loggers.\n\n        Returns:\n            A dict of loggers.\n        \"\"\"\n\n        if \"starlite\" not in value:\n            value[\"starlite\"] = {\n                \"level\": \"INFO\",\n                \"handlers\": [\"queue_listener\"],\n            }\n        return value\n\n    def configure(self) -> \"GetLogger\":\n        \"\"\"Configured logger with the given configuration.\n\n        Returns:\n            A 'logging.getLogger' like function.\n        \"\"\"\n        try:\n            if \"picologging\" in str(dumps(self.handlers)):\n\n                from picologging import (  # pylint: disable=import-outside-toplevel\n                    config,\n                    getLogger,\n                )\n\n                values = self.dict(exclude_none=True, exclude={\"incremental\"})\n            else:\n                from logging import (  # type: ignore[no-redef]  # pylint: disable=import-outside-toplevel\n                    config,\n                    getLogger,\n                )\n\n                values = self.dict(exclude_none=True)\n            config.dictConfig(values)\n            return cast(\"Callable[[str], Logger]\", getLogger)\n        except ImportError as e:  # pragma: no cover\n            raise MissingDependencyException(\"picologging is not installed\") from e\n\n\ndef default_structlog_processors() -> Optional[Iterable[Processor]]:  # pyright: ignore\n    \"\"\"Sets the default processors for structlog.\n\n    Returns:\n        An optional list of processors.\n    \"\"\"\n    try:\n        import structlog  # pylint: disable=import-outside-toplevel\n\n        return [\n            structlog.contextvars.merge_contextvars,\n            structlog.processors.add_log_level,\n            structlog.processors.format_exc_info,\n            structlog.processors.TimeStamper(fmt=\"iso\", utc=True),\n            structlog.processors.JSONRenderer(serializer=dumps),\n        ]\n    except ImportError:  # pragma: no cover\n        return None\n\n\ndef default_wrapper_class() -> Optional[Type[BindableLogger]]:  # pyright: ignore\n    \"\"\"Sets the default wrapper class for structlog.\n\n    Returns:\n        An optional wrapper class.\n    \"\"\"\n\n    try:\n        import structlog  # pylint: disable=import-outside-toplevel\n\n        return structlog.make_filtering_bound_logger(INFO)\n    except ImportError:  # pragma: no cover\n        return None\n\n\ndef default_logger_factory() -> Optional[Callable[..., WrappedLogger]]:\n    \"\"\"Sets the default logger factory for structlog.\n\n    Returns:\n        An optional logger factory.\n    \"\"\"\n    try:\n        import structlog  # pylint: disable=import-outside-toplevel\n\n        return structlog.BytesLoggerFactory()\n    except ImportError:  # pragma: no cover\n        return None\n\n\nclass StructLoggingConfig(BaseLoggingConfig, BaseModel):\n    \"\"\"Configuration class for structlog.\n\n    Notes:\n        - requires 'structlog' to be installed.\n    \"\"\"\n\n    processors: Optional[Iterable[Processor]] = Field(default_factory=default_structlog_processors)  # pyright: ignore\n    \"\"\"Iterable of structlog logging processors.\"\"\"\n    wrapper_class: Optional[Type[BindableLogger]] = Field(default_factory=default_wrapper_class)  # pyright: ignore\n    \"\"\"Structlog bindable logger.\"\"\"\n    context_class: Optional[Dict[str, Any]] = None\n    \"\"\"Context class (a 'contextvar' context) for the logger\"\"\"\n    logger_factory: Optional[Callable[..., WrappedLogger]] = Field(default_factory=default_logger_factory)\n    \"\"\"Logger factory to use.\"\"\"\n    cache_logger_on_first_use: bool = True\n    \"\"\"Whether to cache the logger configuration and reuse. \"\"\"\n\n    def configure(self) -> \"GetLogger\":\n        \"\"\"Configured logger with the given configuration.\n\n        Returns:\n            A 'logging.getLogger' like function.\n        \"\"\"\n        try:\n            from structlog import (  # pylint: disable=import-outside-toplevel\n                configure,\n                get_logger,\n            )\n\n            # we now configure structlog\n            configure(**self.dict(exclude={\"standard_lib_logging_config\"}))\n            return get_logger\n        except ImportError as e:  # pragma: no cover\n            raise MissingDependencyException(\"structlog is not installed\") from e\n", "path": "starlite/config/logging.py"}], "after_files": [{"content": "import atexit\nfrom logging import StreamHandler\nfrom logging.handlers import QueueHandler, QueueListener\nfrom queue import Queue\nfrom typing import Any, List, Optional\n\nfrom starlite.logging.utils import resolve_handlers\n\n\nclass QueueListenerHandler(QueueHandler):\n    def __init__(self, handlers: Optional[List[Any]] = None) -> None:\n        \"\"\"Configures queue listener and handler to support non-blocking\n        logging configuration.\n\n        Args:\n            handlers: Optional 'ConvertingList'\n        \"\"\"\n        super().__init__(Queue(-1))\n        if handlers:\n            handlers = resolve_handlers(handlers)\n        else:\n            handlers = [StreamHandler()]\n        self.listener = QueueListener(self.queue, *handlers)\n        self.listener.start()\n\n        atexit.register(self.listener.stop)\n", "path": "starlite/logging/standard.py"}, {"content": "import atexit\nfrom logging import StreamHandler\nfrom queue import Queue\nfrom typing import Any, List, Optional\n\nfrom starlite.exceptions import MissingDependencyException\nfrom starlite.logging.utils import resolve_handlers\n\ntry:\n    from picologging.handlers import QueueHandler, QueueListener\nexcept ImportError as e:\n    raise MissingDependencyException(\"picologging is not installed\") from e\n\n\nclass QueueListenerHandler(QueueHandler):  # type: ignore[misc]\n    def __init__(self, handlers: Optional[List[Any]] = None) -> None:\n        \"\"\"Configures queue listener and handler to support non-blocking\n        logging configuration.\n\n        Args:\n            handlers: Optional 'ConvertingList'\n\n        Notes:\n            - Requires `picologging` to be installed.\n        \"\"\"\n        super().__init__(Queue(-1))\n        if handlers:\n            handlers = resolve_handlers(handlers)\n        else:\n            handlers = [StreamHandler()]\n        self.listener = QueueListener(self.queue, *handlers)\n        self.listener.start()\n\n        atexit.register(self.listener.stop)\n", "path": "starlite/logging/picologging.py"}, {"content": "from abc import ABC, abstractmethod\nfrom importlib.util import find_spec\nfrom logging import INFO\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    Callable,\n    Dict,\n    Iterable,\n    List,\n    Optional,\n    Type,\n    Union,\n    cast,\n)\n\nfrom orjson import dumps\nfrom pydantic import BaseModel, Field, validator\nfrom typing_extensions import Literal\n\nfrom starlite.exceptions import (\n    ImproperlyConfiguredException,\n    MissingDependencyException,\n)\n\nif TYPE_CHECKING:\n    from starlite.types import Logger\n    from starlite.types.callable_types import GetLogger\n\ntry:\n    from structlog.types import BindableLogger, Processor, WrappedLogger\nexcept ImportError:\n    BindableLogger = Any  # type: ignore\n    Processor = Any  # type: ignore\n    WrappedLogger = Any  # type: ignore\n\n\ndefault_handlers: Dict[str, Dict[str, Any]] = {\n    \"console\": {\n        \"class\": \"logging.StreamHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n    \"queue_listener\": {\n        \"class\": \"starlite.logging.standard.QueueListenerHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n}\n\ndefault_picologging_handlers: Dict[str, Dict[str, Any]] = {\n    \"console\": {\n        \"class\": \"picologging.StreamHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n    \"queue_listener\": {\n        \"class\": \"starlite.logging.picologging.QueueListenerHandler\",\n        \"level\": \"DEBUG\",\n        \"formatter\": \"standard\",\n    },\n}\n\n\ndef get_default_handlers() -> Dict[str, Dict[str, Any]]:\n    \"\"\"\n\n    Returns:\n        The default handlers for the config.\n    \"\"\"\n    if find_spec(\"picologging\"):\n        return default_picologging_handlers\n    return default_handlers\n\n\ndef get_logger_placeholder(_: str) -> Any:  # pragma: no cover\n    \"\"\"\n    Raises:\n        ImproperlyConfiguredException\n    \"\"\"\n    raise ImproperlyConfiguredException(\n        \"To use 'app.get_logger', 'request.get_logger' or 'socket.get_logger' pass 'logging_config' to the Starlite constructor\"\n    )\n\n\nclass BaseLoggingConfig(ABC):  # pragma: no cover\n    \"\"\"Abstract class that should be extended by logging configs.\"\"\"\n\n    __slots__ = ()\n\n    @abstractmethod\n    def configure(self) -> \"GetLogger\":\n        \"\"\"Configured logger with the given configuration.\n\n        Returns:\n            A 'logging.getLogger' like function.\n        \"\"\"\n        raise NotImplementedError(\"abstract method\")\n\n\nclass LoggingConfig(BaseLoggingConfig, BaseModel):\n    \"\"\"Configuration class for standard logging.\n\n    Notes:\n        - If 'picologging' is installed it will be used by default.\n    \"\"\"\n\n    version: Literal[1] = 1\n    \"\"\"The only valid value at present is 1.\"\"\"\n    incremental: bool = False\n    \"\"\"Whether the configuration is to be interpreted as incremental to the existing configuration.\n\n    Notes:\n        - This option is ignored for 'picologging'\n    \"\"\"\n    disable_existing_loggers: bool = False\n    \"\"\"Whether any existing non-root loggers are to be disabled.\"\"\"\n    filters: Optional[Dict[str, Dict[str, Any]]] = None\n    \"\"\"A dict in which each key is a filter id and each value is a dict describing how to configure the corresponding Filter instance.\"\"\"\n    propagate: bool = True\n    \"\"\"If messages must propagate to handlers higher up the logger hierarchy from this logger.\"\"\"\n    formatters: Dict[str, Dict[str, Any]] = {\n        \"standard\": {\"format\": \"%(levelname)s - %(asctime)s - %(name)s - %(module)s - %(message)s\"}\n    }\n    handlers: Dict[str, Dict[str, Any]] = Field(default_factory=get_default_handlers)\n    \"\"\"A dict in which each key is a handler id and each value is a dict describing how to configure the corresponding Handler instance.\"\"\"\n    loggers: Dict[str, Dict[str, Any]] = {\n        \"starlite\": {\n            \"level\": \"INFO\",\n            \"handlers\": [\"queue_listener\"],\n        },\n    }\n    \"\"\"A dict in which each key is a logger name and each value is a dict describing how to configure the corresponding Logger instance.\"\"\"\n    root: Dict[str, Union[Dict[str, Any], List[Any], str]] = {\n        \"handlers\": [\"queue_listener\"],\n        \"level\": \"INFO\",\n    }\n    \"\"\"This will be the configuration for the root logger. Processing of the configuration will be as for any logger,\n    except that the propagate setting will not be applicable.\"\"\"\n\n    @validator(\"handlers\", always=True)\n    def validate_handlers(  # pylint: disable=no-self-argument\n        cls, value: Dict[str, Dict[str, Any]]\n    ) -> Dict[str, Dict[str, Any]]:\n        \"\"\"\n        Ensures that 'queue_listener' is always set\n        Args:\n            value: A dict of route handlers.\n\n        Returns:\n            A dict of route handlers.\n        \"\"\"\n        if \"queue_listener\" not in value:\n            value[\"queue_listener\"] = get_default_handlers()[\"queue_listener\"]\n        return value\n\n    @validator(\"loggers\", always=True)\n    def validate_loggers(  # pylint: disable=no-self-argument\n        cls, value: Dict[str, Dict[str, Any]]\n    ) -> Dict[str, Dict[str, Any]]:\n        \"\"\"Ensures that the 'starlite' logger is always set.\n\n        Args:\n            value: A dict of loggers.\n\n        Returns:\n            A dict of loggers.\n        \"\"\"\n\n        if \"starlite\" not in value:\n            value[\"starlite\"] = {\n                \"level\": \"INFO\",\n                \"handlers\": [\"queue_listener\"],\n            }\n        return value\n\n    def configure(self) -> \"GetLogger\":\n        \"\"\"Configured logger with the given configuration.\n\n        Returns:\n            A 'logging.getLogger' like function.\n        \"\"\"\n        try:\n            if \"picologging\" in str(dumps(self.handlers)):\n\n                from picologging import (  # pylint: disable=import-outside-toplevel\n                    config,\n                    getLogger,\n                )\n\n                values = self.dict(exclude_none=True, exclude={\"incremental\"})\n            else:\n                from logging import (  # type: ignore[no-redef]  # pylint: disable=import-outside-toplevel\n                    config,\n                    getLogger,\n                )\n\n                values = self.dict(exclude_none=True)\n            config.dictConfig(values)\n            return cast(\"Callable[[str], Logger]\", getLogger)\n        except ImportError as e:  # pragma: no cover\n            raise MissingDependencyException(\"picologging is not installed\") from e\n\n\ndef default_structlog_processors() -> Optional[Iterable[Processor]]:  # pyright: ignore\n    \"\"\"Sets the default processors for structlog.\n\n    Returns:\n        An optional list of processors.\n    \"\"\"\n    try:\n        import structlog  # pylint: disable=import-outside-toplevel\n\n        return [\n            structlog.contextvars.merge_contextvars,\n            structlog.processors.add_log_level,\n            structlog.processors.format_exc_info,\n            structlog.processors.TimeStamper(fmt=\"iso\", utc=True),\n            structlog.processors.JSONRenderer(serializer=dumps),\n        ]\n    except ImportError:  # pragma: no cover\n        return None\n\n\ndef default_wrapper_class() -> Optional[Type[BindableLogger]]:  # pyright: ignore\n    \"\"\"Sets the default wrapper class for structlog.\n\n    Returns:\n        An optional wrapper class.\n    \"\"\"\n\n    try:\n        import structlog  # pylint: disable=import-outside-toplevel\n\n        return structlog.make_filtering_bound_logger(INFO)\n    except ImportError:  # pragma: no cover\n        return None\n\n\ndef default_logger_factory() -> Optional[Callable[..., WrappedLogger]]:\n    \"\"\"Sets the default logger factory for structlog.\n\n    Returns:\n        An optional logger factory.\n    \"\"\"\n    try:\n        import structlog  # pylint: disable=import-outside-toplevel\n\n        return structlog.BytesLoggerFactory()\n    except ImportError:  # pragma: no cover\n        return None\n\n\nclass StructLoggingConfig(BaseLoggingConfig, BaseModel):\n    \"\"\"Configuration class for structlog.\n\n    Notes:\n        - requires 'structlog' to be installed.\n    \"\"\"\n\n    processors: Optional[Iterable[Processor]] = Field(default_factory=default_structlog_processors)  # pyright: ignore\n    \"\"\"Iterable of structlog logging processors.\"\"\"\n    wrapper_class: Optional[Type[BindableLogger]] = Field(default_factory=default_wrapper_class)  # pyright: ignore\n    \"\"\"Structlog bindable logger.\"\"\"\n    context_class: Optional[Dict[str, Any]] = None\n    \"\"\"Context class (a 'contextvar' context) for the logger\"\"\"\n    logger_factory: Optional[Callable[..., WrappedLogger]] = Field(default_factory=default_logger_factory)\n    \"\"\"Logger factory to use.\"\"\"\n    cache_logger_on_first_use: bool = True\n    \"\"\"Whether to cache the logger configuration and reuse. \"\"\"\n\n    def configure(self) -> \"GetLogger\":\n        \"\"\"Configured logger with the given configuration.\n\n        Returns:\n            A 'logging.getLogger' like function.\n        \"\"\"\n        try:\n            from structlog import (  # pylint: disable=import-outside-toplevel\n                configure,\n                get_logger,\n            )\n\n            # we now configure structlog\n            configure(**self.dict(exclude={\"standard_lib_logging_config\"}))\n            return get_logger\n        except ImportError as e:  # pragma: no cover\n            raise MissingDependencyException(\"structlog is not installed\") from e\n", "path": "starlite/config/logging.py"}]}