refactor!: Remove error snapshot
This commit is contained in:
parent
b9f000e1f9
commit
ae8ee5064c
15 changed files with 60 additions and 386 deletions
|
|
@ -1,12 +0,0 @@
|
|||
{% if (Object.prototype.toString.call(x) === "[object Object]") { %}
|
||||
<table class="table">
|
||||
{% for (var key in x) { %}
|
||||
<tr>
|
||||
<td><code>{{ key }}</code></td>
|
||||
<td>{{ x[key] }}</td>
|
||||
</tr>
|
||||
{% } %}
|
||||
</table>
|
||||
{% } else { %}
|
||||
{{ x }}
|
||||
{% } %}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<style>
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.codebox {
|
||||
font-family: monospace;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
.codebox .line.current {
|
||||
background: rgba(0,0,255, 0.1);
|
||||
}
|
||||
|
||||
.codebox .lineno {
|
||||
text-align: right;
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.codebox .code {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.object-link {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
</style>
|
||||
{% function id(){ return id._old_id++; }; id._old_id = 0; %}
|
||||
<h3>{{ __("Error Report") }}</h3>
|
||||
<p class="text-muted">{{ doc.pyver }}</p>
|
||||
<dl>
|
||||
<dt>{{ __("Timestamp") }}: </dt>
|
||||
<dd>{{ doc.timestamp }}</dd>
|
||||
<dt>{{ __("Relapsed") }}</dt>
|
||||
<dd><code>{{ doc.relapses }}</code></dd>
|
||||
</dl>
|
||||
|
||||
<h3>{{ __("Exception") }}</h3>
|
||||
{{ frappe.render_template("error_object", {x: JSON.parse(doc.exception)}) }}
|
||||
|
||||
<h3>{{ __("Locals") }}</h3>
|
||||
{{ frappe.render_template("error_object", {x: JSON.parse(doc.locals)} )}}
|
||||
|
||||
<h3>{{ __("Traceback") }}</h3>
|
||||
{% var frames = JSON.parse(doc.frames); %}
|
||||
{% for (var i in frames) { %}
|
||||
{% var frameid = id(), frame = frames[i] %}
|
||||
<p><i class="octicon octicon-file-text"></i> <code>{{ frame.file }}: {{ frame.lnum }}</code>
|
||||
<div class="row">
|
||||
<div class="codebox">
|
||||
<div class="col-lg-11">
|
||||
{% for (var index in frame.lines) { %}
|
||||
{% var line = frame.lines[index] %}
|
||||
<div class="line {{ index == frame.lnum ? "current": "" }}">
|
||||
<span class="lineno text-muted">{{ index }}</span>
|
||||
<span class="code">{{ line }}</span>
|
||||
</div>
|
||||
{% } %}
|
||||
</div>
|
||||
<div class="col-lg-1">
|
||||
<span class="btn btn-xs btn-default" data-toggle="collapse" data-target="#frame-{{ frameid }}-locals">
|
||||
<i class="fa fa-list-ul"> {{ __("Locals") }}</i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 collapse" id="frame-{{ frameid }}-locals">
|
||||
<h4>{{ __("Locals") }}</h4>
|
||||
{{ frappe.render_template("error_object", {x: frame.dump }) }}
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
{% } %}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
frappe.ui.form.on("Error Snapshot", "load", function (frm) {
|
||||
frm.set_read_only(true);
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Error Snapshot", "refresh", function (frm) {
|
||||
frm.set_df_property(
|
||||
"view",
|
||||
"options",
|
||||
frappe.render_template("error_snapshot", { doc: frm.doc })
|
||||
);
|
||||
|
||||
if (frm.doc.relapses) {
|
||||
frm.add_custom_button(__("Show Relapses"), function () {
|
||||
frappe.route_options = {
|
||||
parent_error_snapshot: frm.doc.name,
|
||||
};
|
||||
frappe.set_route("List", "Error Snapshot");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
{
|
||||
"actions": [],
|
||||
"creation": "2015-11-28 00:57:39.766888",
|
||||
"doctype": "DocType",
|
||||
"document_type": "System",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"view",
|
||||
"seen",
|
||||
"evalue",
|
||||
"timestamp",
|
||||
"relapses",
|
||||
"etype",
|
||||
"traceback",
|
||||
"parent_error_snapshot",
|
||||
"pyver",
|
||||
"exception",
|
||||
"locals",
|
||||
"frames"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "view",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Snapshot View"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "seen",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"in_filter": 1,
|
||||
"label": "Seen"
|
||||
},
|
||||
{
|
||||
"fieldname": "evalue",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Friendly Title",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "timestamp",
|
||||
"fieldtype": "Datetime",
|
||||
"hidden": 1,
|
||||
"label": "Timestamp",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"fieldname": "relapses",
|
||||
"fieldtype": "Int",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Relapses",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "etype",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "Exception Type",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "traceback",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 1,
|
||||
"label": "Traceback",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "parent_error_snapshot",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "Parent Error Snapshot"
|
||||
},
|
||||
{
|
||||
"fieldname": "pyver",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 1,
|
||||
"label": "Pyver",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "exception",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 1,
|
||||
"label": "Exception"
|
||||
},
|
||||
{
|
||||
"fieldname": "locals",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 1,
|
||||
"label": "Locals"
|
||||
},
|
||||
{
|
||||
"fieldname": "frames",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 1,
|
||||
"label": "Frames"
|
||||
}
|
||||
],
|
||||
"in_create": 1,
|
||||
"links": [],
|
||||
"modified": "2022-08-03 12:20:53.504160",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Error Snapshot",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Administrator",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "timestamp",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "evalue"
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.query_builder import Interval
|
||||
from frappe.query_builder.functions import Now
|
||||
|
||||
|
||||
class ErrorSnapshot(Document):
|
||||
no_feed_on_delete = True
|
||||
|
||||
def onload(self):
|
||||
if not self.parent_error_snapshot:
|
||||
self.db_set("seen", 1, update_modified=False)
|
||||
|
||||
for relapsed in frappe.get_all("Error Snapshot", filters={"parent_error_snapshot": self.name}):
|
||||
frappe.db.set_value("Error Snapshot", relapsed.name, "seen", 1, update_modified=False)
|
||||
|
||||
frappe.local.flags.commit = True
|
||||
|
||||
def validate(self):
|
||||
parent = frappe.get_all(
|
||||
"Error Snapshot",
|
||||
filters={"evalue": self.evalue, "parent_error_snapshot": ""},
|
||||
fields=["name", "relapses", "seen"],
|
||||
limit_page_length=1,
|
||||
)
|
||||
|
||||
if parent:
|
||||
parent = parent[0]
|
||||
self.update({"parent_error_snapshot": parent["name"]})
|
||||
frappe.db.set_value("Error Snapshot", parent["name"], "relapses", parent["relapses"] + 1)
|
||||
if parent["seen"]:
|
||||
frappe.db.set_value("Error Snapshot", parent["name"], "seen", 0)
|
||||
|
||||
@staticmethod
|
||||
def clear_old_logs(days=30):
|
||||
table = frappe.qb.DocType("Error Snapshot")
|
||||
frappe.db.delete(table, filters=(table.modified < (Now() - Interval(days=days))))
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
frappe.listview_settings["Error Snapshot"] = {
|
||||
add_fields: ["parent_error_snapshot", "relapses", "seen"],
|
||||
filters: [
|
||||
["parent_error_snapshot", "=", null],
|
||||
["seen", "=", false],
|
||||
],
|
||||
get_indicator: function (doc) {
|
||||
if (doc.parent_error_snapshot && doc.parent_error_snapshot.length) {
|
||||
return [__("Relapsed"), !doc.seen ? "orange" : "blue", "parent_error_snapshot,!=,"];
|
||||
} else {
|
||||
return [__("First Level"), !doc.seen ? "red" : "green", "parent_error_snapshot,=,"];
|
||||
}
|
||||
},
|
||||
onload: function (listview) {
|
||||
frappe.require("logtypes.bundle.js", () => {
|
||||
frappe.utils.logtypes.show_log_retention_message(cur_list.doctype);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
from frappe.utils.logger import sanitized_dict
|
||||
|
||||
# test_records = frappe.get_test_records('Error Snapshot')
|
||||
|
||||
|
||||
class TestErrorSnapshot(FrappeTestCase):
|
||||
def test_form_dict_sanitization(self):
|
||||
self.assertNotEqual(sanitized_dict({"pwd": "SECRET", "usr": "WHAT"}).get("pwd"), "SECRET")
|
||||
|
|
@ -14,7 +14,6 @@ DEFAULT_LOGTYPES_RETENTION = {
|
|||
"Error Log": 30,
|
||||
"Activity Log": 90,
|
||||
"Email Queue": 30,
|
||||
"Error Snapshot": 30,
|
||||
"Scheduled Job Log": 90,
|
||||
"Route History": 90,
|
||||
"Submission Queue": 30,
|
||||
|
|
@ -156,7 +155,6 @@ LOG_DOCTYPES = [
|
|||
"Route History",
|
||||
"Email Queue",
|
||||
"Email Queue Recipient",
|
||||
"Error Snapshot",
|
||||
"Error Log",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ class TestLogSettings(FrappeTestCase):
|
|||
"Activity Log",
|
||||
"Email Queue",
|
||||
"Route History",
|
||||
"Error Snapshot",
|
||||
"Scheduled Job Log",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ def get_notification_config():
|
|||
"Communication": {"status": "Open", "communication_type": "Communication"},
|
||||
"ToDo": "frappe.core.notifications.get_things_todo",
|
||||
"Event": "frappe.core.notifications.get_todays_events",
|
||||
"Error Snapshot": {"seen": 0, "parent_error_snapshot": None},
|
||||
"Workflow Action": {"status": "Open"},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,74 +155,6 @@
|
|||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "System Logs",
|
||||
"link_count": 6,
|
||||
"onboard": 0,
|
||||
"type": "Card Break"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Background Jobs",
|
||||
"link_count": 0,
|
||||
"link_to": "RQ Job",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Scheduled Jobs Logs",
|
||||
"link_count": 0,
|
||||
"link_to": "Scheduled Job Log",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Error Logs",
|
||||
"link_count": 0,
|
||||
"link_to": "Error Log",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Error Snapshot",
|
||||
"link_count": 0,
|
||||
"link_to": "Error Snapshot",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Communication Logs",
|
||||
"link_count": 0,
|
||||
"link_to": "Communication",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Activity Log",
|
||||
"link_count": 0,
|
||||
"link_to": "Activity Log",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
|
|
@ -331,9 +263,67 @@
|
|||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "System Logs",
|
||||
"link_count": 5,
|
||||
"onboard": 0,
|
||||
"type": "Card Break"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Background Jobs",
|
||||
"link_count": 0,
|
||||
"link_to": "RQ Job",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Scheduled Jobs Logs",
|
||||
"link_count": 0,
|
||||
"link_to": "Scheduled Job Log",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Error Logs",
|
||||
"link_count": 0,
|
||||
"link_to": "Error Log",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Communication Logs",
|
||||
"link_count": 0,
|
||||
"link_to": "Communication",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Activity Log",
|
||||
"link_count": 0,
|
||||
"link_to": "Activity Log",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2023-05-24 14:47:24.395259",
|
||||
"modified": "2023-06-28 10:30:17.228167",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Build",
|
||||
|
|
|
|||
|
|
@ -617,7 +617,6 @@ def make_site_dirs():
|
|||
os.path.join("public", "files"),
|
||||
os.path.join("private", "backups"),
|
||||
os.path.join("private", "files"),
|
||||
"error-snapshots",
|
||||
"locks",
|
||||
"logs",
|
||||
]:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ execute:frappe.reload_doc('core', 'doctype', 'user') #2017-10-27
|
|||
execute:frappe.reload_doc('core', 'doctype', 'report_column')
|
||||
execute:frappe.reload_doc('core', 'doctype', 'report_filter')
|
||||
execute:frappe.reload_doc('core', 'doctype', 'report') #2020-08-25
|
||||
execute:frappe.reload_doc('core', 'doctype', 'error_snapshot')
|
||||
execute:frappe.get_doc("User", "Guest").save()
|
||||
execute:frappe.delete_doc("DocType", "Control Panel", force=1)
|
||||
execute:frappe.delete_doc("DocType", "Tag")
|
||||
|
|
@ -42,7 +41,6 @@ execute:frappe.db.sql("delete from `tabProperty Setter` where `property` = 'idx'
|
|||
execute:frappe.db.sql("delete from tabSessions where user is null")
|
||||
execute:frappe.delete_doc("DocType", "Backup Manager")
|
||||
execute:frappe.permissions.reset_perms("Web Page")
|
||||
execute:frappe.permissions.reset_perms("Error Snapshot")
|
||||
execute:frappe.db.sql("delete from `tabWeb Page` where ifnull(template_path, '')!=''")
|
||||
execute:frappe.core.doctype.language.language.update_language_names() # 2017-04-12
|
||||
execute:frappe.db.set_value("Print Settings", "Print Settings", "add_draft_heading", 1)
|
||||
|
|
@ -227,3 +225,4 @@ frappe.patches.v15_0.remove_background_jobs_from_dropdown
|
|||
frappe.desk.doctype.form_tour.patches.introduce_ui_tours
|
||||
execute:frappe.delete_doc_if_exists("Workspace", "Customization")
|
||||
execute:frappe.db.set_single_value("Document Naming Settings", "default_amend_naming", "Amend Counter")
|
||||
execute:frappe.delete_doc_if_exists("DocType", "Error Snapshot")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ def execute():
|
|||
"Email Queue": get_current_setting("clear_email_queue_after") or 30,
|
||||
# child table on email queue
|
||||
"Email Queue Recipient": get_current_setting("clear_email_queue_after") or 30,
|
||||
"Error Snapshot": get_current_setting("clear_error_log_after") or 90,
|
||||
# newly added
|
||||
"Scheduled Job Log": 90,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue