Skip to content

Commit da1c646

Browse files
committed
Add missing files
1 parent f05a3e6 commit da1c646

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
title: Version 24.6
3+
---
4+
5+
# Version 24.6
6+
7+
.. toc::
8+
9+
10+
## Introduction
11+
12+
This is the first release of the version 24 [release cycle](../../organization/policies.md#release-schedule). The release cadence for v24 may be slightly altered from years past. Make sure to stay up to date in the Discord server for latest updates. If you run into any issues, please raise a concern on [GitHub](https://github.com/sanic-org/sanic/issues/new/choose).
13+
14+
## What to know
15+
16+
More details in the [Changelog](../changelog.html). Notable new or breaking features, and what to upgrade:
17+
18+
### Logging improvements
19+
20+
The default logging patterns have been cleaned up to make them much more developer-friendly when viewing from a terminal session. This includes the use of color and less verbose formatting.
21+
22+
Sanic will select between two slight variations depending upon whether your server is in DEBUG mode. You can always opt to remove colors by using:
23+
24+
```python
25+
app.config.NO_COLOR = True
26+
```
27+
28+
The color will automatically be stripped out from logs not in TTY terminal.
29+
30+
Sanic will switch between the DEBUG and PROD formatters automatically using `sanic.logging.formatter.AutoFormatter` and `sanic.logging.formatter.AutoAccessFormatter`. Of course, you can force one version or the other using the appropriately named formatters
31+
32+
#### In DEBUG mode
33+
34+
```python
35+
sanic.logging.formatter.DebugFormatter
36+
sanic.logging.formatter.DebugAccessFormatter
37+
```
38+
39+
![](/assets/images/logging-dev.png)
40+
41+
#### In PROD mode
42+
43+
44+
```python
45+
sanic.logging.formatter.ProdFormatter
46+
sanic.logging.formatter.ProdAccessFormatter
47+
```
48+
49+
![](/assets/images/logging-prod.png)
50+
51+
#### Legacy
52+
53+
If you prefer the old-style of logging, these have been preserved for you as logging formatters: `sanic.logging.formatter.LegacyFormatter` and `sanic.logging.formatter.LegacyAccessFormatter`.
54+
55+
One way to implement these formatters:
56+
57+
```python
58+
from sanic.log import LOGGING_CONFIG_DEFAULTS
59+
60+
LOGGING_CONFIG_DEFAULTS["formatters"] = {
61+
"generic": {
62+
"class": "sanic.logging.formatter.LegacyFormatter"
63+
},
64+
"access": {
65+
"class": "sanic.logging.formatter.LegacyAccessFormatter"
66+
},
67+
}
68+
```
69+
70+
#### New JSON formatter
71+
72+
There also is a new JSON log formatter that will output the logs in JSON format for integration with other third part logging platforms.
73+
74+
75+
```python
76+
from sanic.log import LOGGING_CONFIG_DEFAULTS
77+
78+
LOGGING_CONFIG_DEFAULTS["formatters"] = {
79+
"generic": {
80+
"class": "sanic.logging.formatter.JSONFormatter"
81+
},
82+
"access": {
83+
"class": "sanic.logging.formatter.JSONAccessFormatter"
84+
},
85+
}
86+
```
87+
88+
### Using Paths in unix sockets
89+
90+
When creating a unix socket for your server, you can now perform that by passing a `pathlib.Path` object instead of just a string-based path
91+
92+
### Custom route names
93+
94+
You can override the `generate_name` method on either a custom `Sanic` or a `Blueprint`. This will allow you to modify the route names at will.
95+
96+
```python
97+
from sanic import Sanic, text,
98+
99+
class Custom(Sanic):
100+
def generate_name(self, *objects):
101+
existing = self._generate_name(*objects)
102+
return existing.upper()
103+
104+
app = Sanic("Foo")
105+
106+
@app.get("/")
107+
async def handler(request):
108+
return text(request.name) # FOO.HANDLER
109+
110+
111+
return app
112+
```
113+
114+
### 🚨 BREAKING CHANGES
115+
116+
1. `Request.cookies.getlist` always returns a `list`. This means when no cookie of `key` exists, it will be an empty `list` instead of `None`. Use `Request.cookies.getlist("something", None)` to retain existing behavior.
117+
118+
119+
## Thank you
120+
121+
Thank you to everyone that participated in this release: :clap:
122+
123+
[@ahopkins](https://github.com/ahopkins)
124+
[@ashleysommer](https://github.com/ashleysommer)
125+
[@ChihweiLHBird](https://github.com/ChihweiLHBird)
126+
[@DeJayDev](https://github.com/DeJayDev)
127+
[@ekzhang](https://github.com/ekzhang)
128+
[@Huy-Ngo](https://github.com/Huy-Ngo)
129+
[@iAndriy](https://github.com/iAndriy)
130+
[@jakkaz](https://github.com/jakkaz)
131+
[@Nano112](https://github.com/Nano112)
132+
[@prryplatypus](https://github.com/prryplatypus)
133+
[@razodactyl](https://github.com/razodactyl)
134+
[@Tronic](https://github.com/Tronic)
135+
[@wieczorek1990](https://github.com/wieczorek1990)
136+
137+
---
138+
139+
If you enjoy the project, please consider contributing. Of course we love code contributions, but we also love contributions in any form. Consider writing some documentation, showing off use cases, joining conversations and making your voice known, and if you are able: [financial contributions](https://opencollective.com/sanic-org/).
Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)