Zend_Log 的 UML 类图正确吗?

发布于 2024-09-17 22:31:06 字数 998 浏览 16 评论 0原文

问题背景

对 Zend_Log 的分析揭示了以下类图

Zend_Log:

  • 使用 ReflectionClass & Zend_Log_Exception
  • 维护对 Zend_Log_Writer_Abstract 数组的引用
  • 维护对 Zend_Log_Filter_Interface 数组的

引用Zend_Log_Writer_Abstract

  • 维护对 Zend_Log_Filter_Interface 数组的引用
  • 维护对 Zend_Log_Formatter_Interface 的引用

alt text

问题

  1. Zend_Log_Filter_Interface 与 Zend_Log_Filter_Suppress、Zend_Log_Filter_Message 和 Zend_Log_Filter_Message 相关。 Zend_Log_Filter_Priority 如图所示,在类图中的布局是否正确?
  2. 可以这么说吗,Zend_Log 包含对 Zend_Log_Filter_Interface 数组的引用,这是组合关系(与 Zend_Log_Writer_Abstract 类似)?
  3. 很明显,Zend_Log_Filter_Interface 包含在 Zend_Log 和 Zend_Log 中。 Zend_Log_Writer_Abstract,而Zend_Log包含Zend_Log_Writer_Abstract,这使得Zend_Log_Filter既被容器(Zend_Log)引用又被包含(Zend_Log_Writer_Abstract)引用;是某种“设计模式”吗?如果是的话,名字是什么?

问候!

Background of question

Analysis of Zend_Log reveals following Class Diagram

Zend_Log:

  • uses ReflectionClass & Zend_Log_Exception
  • maintains reference to array of Zend_Log_Writer_Abstract
  • maintains references to array of Zend_Log_Filter_Interface

Zend_Log_Writer_Abstract

  • maintains reference to array of Zend_Log_Filter_Interface
  • maintains reference to Zend_Log_Formatter_Interface

alt text

Questions

  1. Zend_Log_Filter_Interface relates with Zend_Log_Filter_Suppress, Zend_Log_Filter_Message & Zend_Log_Filter_Priority as depicted, is this correctly laid out in Class Diagram?
  2. Is it okay to say that, the Zend_Log contains reference to array of Zend_Log_Filter_Interface and this is composition relationship (similarly for Zend_Log_Writer_Abstract)?
  3. As it is obvious that Zend_Log_Filter_Interface is contained by both Zend_Log & Zend_Log_Writer_Abstract, while Zend_Log contains Zend_Log_Writer_Abstract, that makes Zend_Log_Filter referenced by both container (Zend_Log) and contained (Zend_Log_Writer_Abstract); is that some "Design Pattern", if yes what is the name?

Regards!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦忆晨望 2024-09-24 22:31:06
  1. Zend_Log_Filter_SuppressZend_Log_Filter_MessageZend_Log_Filter_Priority 都实现了 Zend_Log_Filter_Interface 接口。这是使用空箭头和它们之间的虚线来表示的。 Zend_Log_Formatter_Interface 及其下面描述的三个类也是如此。

  2. 是的,没错。此处是否使用关联 (-->) 或组合可能存在争议,因为两个 Zend_Log 实例可以共享单个 Zend_Log_Writer_Db 实例。由于编写者和过滤器决定日志的整体行为,因此组合对我来说很有意义。

  3. 每个日志实例可以写入多个写入器。消息首先由日志本身过滤,任何传递的消息都会发送到每个写入者。每个作者也会过滤传入的消息。这允许您忽略写入文件的低于 WARN 优先级(日志级别)的所有消息,并进一步将数据库日志记录限制为 FATAL 级别的日志记录。您可以通过删除日志级别过滤器数组来实现相同的效果,但这需要在每个写入器中重复过滤。

  1. Zend_Log_Filter_Suppress, Zend_Log_Filter_Message, and Zend_Log_Filter_Priority all implement the Zend_Log_Filter_Interface interface. This is denoted using the empty arrow and dotted lines between them. The same is true for Zend_Log_Formatter_Interface and the three classes depicted below it.

  2. Yes, that's correct. Whether to use an association (-->) or composition here could be debated since two Zend_Log instances could share a single Zend_Log_Writer_Db instance. As the writers and filters determine the overall behavior of the log, composition makes sense to me.

  3. Each log instance can write to multiple writers. Messages are first filtered by the log itself, and any message that passes goes to every writer. Each writer filters the incoming messages as well. This allows you to ignore all messages below the WARN priority (at the log level) which get written to a file and further limit database logging to those at the FATAL level. You could accomplish the same effect by dropping the log-level filter array, but it would require duplicating the filtering in each writer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文