异常级别和日志记录 [英] Exception levels and logging

查看:94
本文介绍了异常级别和日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须开发一个与不同信息系统集成的系统。



在开发过程中,有些情况需要在不可预测的情况下发送通过邮件通知,在其他情况下记录日志中的信息,或在紧急情况下发送短信。



对于日志记录和其他通知,我选择了Monolog。 />


问题是,如何组织使用异常以便存在不同级别的异常,并执行适当的操作(记录等)?



我搜索了不同来源的信息,找到了几个描述。一些开发人员为例外创建了3个级别的界面:



UnloggedInterface - 默认情况下会记录所有未处理的错误。此接口标记了根本不需要记录的异常。



PreloggedInterface - 此接口标记需要记录的异常:它们是否被处理并不重要。



OutableInterface - 此界面标记异常,其文本可以给予用户。



我不明白Exception类的继承层次结构应该是什么?



At您需要在什么阶段记录例外?在抛出异常时?或在异常处理时?以及如何处理未处理的异常(如何记录它们?)?



可能需要使用Monolog \ ErrorHandler? (但我不知道怎么样)..



请告诉我怎么样?我在哪里可以看到例子?或者在哪里阅读它?



我很想知道这是如何工作的。并查看包含正确工作的示例。



还可以安排GitHub的示例。



我会感谢任何帮助。



我尝试过:



I have to develop a system of integration with different information systems.

In the development process, there will be cases when it is required in unpredicted situations to send notifications by mail, in other cases to record information in the log, or to send SMS in critical situations.

For logging and other notifications, I chose Monolog.

The question is, how do I organize work with Exceptions so that there are different levels of exceptions, and appropriate actions are performed (logging, etc.)?

I searched for information in different sources, found several descriptions. Some developers create 3 levels interfaces for Exceptions:

UnloggedInterface - all unprocessed errors are logged by default. This interface marks Exceptions that do not need to be logged at all.

PreloggedInterface — this interface marks exceptions that need to be logged anyway: it doesn't matter whether they are processed or not.

OutableInterface - this interface marks exceptions, the text of which can be given to the user.

I do not understand what should be the inheritance hierarchy of Exception classes?

At what stage do you need to log Exceptions? At the time of throwing exceptions? or at the time of Exception handling? and what to do with Exceptions that are not processed (how to log them?)?

May need to use Monolog\ErrorHandler ? (but I dont know how) ..

Please tell me how to be? Where can I see examples? Or where to read about it?

I would love to understand how this works. And look at examples of correct work with inclusions.

Also arrange examples from GitHub.

I would be grateful for any help.

What I have tried:

I read different sources, did not understand how to put it all together

推荐答案

这个东西没有创建在真空中。



通常情况下,有事件导致需要通知系统。



你需要与任何要求你这样做的人交谈并得到一些需要采取行动并被通知的事件的例子。



您记录/了解当前程序;然后你就可以开始考虑自动化/新程序。
This stuff isn't created in a vacuum.

Usually, there are "incidents" that precipitate the need for a "notification" system.

You need to "talk" to whomever asked you to do this and get a few "examples" of incidents that required an action and who was notified.

You document / understand the "current" procedures; then you can start thinking about automation / new procedures.


这篇关于异常级别和日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆