Skip to content

Commit 1e08ade

Browse files
committed
[ADD] fastapi_log_mail
1 parent add156f commit 1e08ade

File tree

15 files changed

+672
-0
lines changed

15 files changed

+672
-0
lines changed

fastapi_log_mail/README.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
===========
2+
Fastapi Log
3+
===========
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ef0c0bceb8ae27bcfebaebc22e2fb4747475f2a2c60dd2d410bc40b6efee9b6a
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
20+
:target: https://github.com/OCA/rest-framework/tree/16.0/fastapi_log_mail
21+
:alt: OCA/rest-framework
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/rest-framework-16-0/rest-framework-16-0-fastapi_log_mail
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows to send an email when an exception occurs in an
32+
endpoint.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Configuration
40+
=============
41+
42+
In any endpoint that has logging enabled, insert an email template in
43+
"Error E-mail Template".
44+
45+
Bug Tracker
46+
===========
47+
48+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
49+
In case of trouble, please check there if your issue has already been reported.
50+
If you spotted it first, help us to smash it by providing a detailed and welcomed
51+
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi_log_mail%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
52+
53+
Do not contact contributors directly about support or help with technical issues.
54+
55+
Credits
56+
=======
57+
58+
Authors
59+
-------
60+
61+
* PyTech
62+
63+
Contributors
64+
------------
65+
66+
- `PyTech <https://www.pytech.it>`__:
67+
68+
- Simone Rubino <[email protected]>
69+
70+
Maintainers
71+
-----------
72+
73+
This module is maintained by the OCA.
74+
75+
.. image:: https://odoo-community.org/logo.png
76+
:alt: Odoo Community Association
77+
:target: https://odoo-community.org
78+
79+
OCA, or the Odoo Community Association, is a nonprofit organization whose
80+
mission is to support the collaborative development of Odoo features and
81+
promote its widespread use.
82+
83+
.. |maintainer-SirPyTech| image:: https://github.com/SirPyTech.png?size=40px
84+
:target: https://github.com/SirPyTech
85+
:alt: SirPyTech
86+
87+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
88+
89+
|maintainer-SirPyTech|
90+
91+
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/16.0/fastapi_log_mail>`_ project on GitHub.
92+
93+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

fastapi_log_mail/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

fastapi_log_mail/__manifest__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2025 Simone Rubino - PyTech
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Fastapi Log",
6+
"version": "16.0.1.0.0",
7+
"license": "AGPL-3",
8+
"author": "PyTech, Odoo Community Association (OCA)",
9+
"maintainers": [
10+
"SirPyTech",
11+
],
12+
"website": "https://github.com/OCA/rest-framework",
13+
"summary": "Email exceptions of Endpoints.",
14+
"category": "Tools",
15+
"depends": [
16+
"fastapi_log",
17+
"mail",
18+
],
19+
"data": [
20+
"views/fastapi_endpoint_views.xml",
21+
],
22+
}

fastapi_log_mail/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import api_log
4+
from . import fastapi_endpoint

fastapi_log_mail/models/api_log.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2025 Simone Rubino - PyTech
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
5+
from odoo import models
6+
7+
8+
class FastapiLog(models.Model):
9+
_inherit = "api.log"
10+
11+
def log_exception(self, exception):
12+
res = super().log_exception(exception)
13+
mail_template = self.fastapi_endpoint_id.fastapi_log_mail_template_id
14+
if mail_template:
15+
mail_template.sudo().send_mail(self.id)
16+
return res
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 Simone Rubino - PyTech
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class FastapiEndpoint(models.Model):
8+
_inherit = "fastapi.endpoint"
9+
10+
fastapi_log_mail_template_id = fields.Many2one(
11+
comodel_name="mail.template",
12+
domain=[("model_id.model", "=", "api.log")],
13+
string="Error E-mail Template",
14+
help="Select the email template that will be sent when an error is logged.",
15+
)

fastapi_log_mail/readme/CONFIGURE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In any endpoint that has logging enabled, insert an email template in "Error E-mail Template".
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [PyTech](https://www.pytech.it):
2+
- Simone Rubino \<<[email protected]>\>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows to send an email when an exception occurs in an endpoint.

0 commit comments

Comments
 (0)