How we develop better apps

We discuss the biggest mistake new Frappe developers make. You can develop better apps with just single line of code.

 · 1 min read

The biggest mistake new Frappe developers make is they don't log.

Just type "error log" in the awesome search bar in ERPNext. You can see the generated error logs. This is how developers get info about the errors in production.

For instance this is how we log SQL Server queries:

if docJLSettings.ld_log_sql_server_queries:

    frappe.log_error(_("Query Result for {0} is {1}").format(strLogDescription, lstResult), _("Jet Lazer"))

So you can review and filter your logs. Error Log List

And you can examine the log: Error Log Detail

You can generate descriptive log messages:

frappe.log_error(frappe.get_traceback(), _("Calculate rate failed in sales order."))

You can enrich them:

frappe.log_error(_("Calculate rate failed in {0}. Customer: {1}, Total:{2}, Error:{3}.").format(doc.doctype, doc.customer, doc.grand_total, frappe.get_traceback()), _("Calculate Rate in My App"))

You can also use:

frappe.errprint("Error occured.")

which prints info to the console on development environment and logs the error. So you can trace it when you need it.


No comments yet.

Add a comment
Ctrl+Enter to add comment