Zend_Log 的 UML 类图正确吗?
问题背景
对 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 的引用
问题
- Zend_Log_Filter_Interface 与 Zend_Log_Filter_Suppress、Zend_Log_Filter_Message 和 Zend_Log_Filter_Message 相关。 Zend_Log_Filter_Priority 如图所示,在类图中的布局是否正确?
- 可以这么说吗,Zend_Log 包含对 Zend_Log_Filter_Interface 数组的引用,这是组合关系(与 Zend_Log_Writer_Abstract 类似)?
- 很明显,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
Questions
- 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?
- 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)?
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Zend_Log_Filter_Suppress
、Zend_Log_Filter_Message
和Zend_Log_Filter_Priority
都实现了Zend_Log_Filter_Interface
接口。这是使用空箭头和它们之间的虚线来表示的。Zend_Log_Formatter_Interface
及其下面描述的三个类也是如此。是的,没错。此处是否使用关联 (-->) 或组合可能存在争议,因为两个
Zend_Log
实例可以共享单个Zend_Log_Writer_Db
实例。由于编写者和过滤器决定日志的整体行为,因此组合对我来说很有意义。每个日志实例可以写入多个写入器。消息首先由日志本身过滤,任何传递的消息都会发送到每个写入者。每个作者也会过滤传入的消息。这允许您忽略写入文件的低于 WARN 优先级(日志级别)的所有消息,并进一步将数据库日志记录限制为 FATAL 级别的日志记录。您可以通过删除日志级别过滤器数组来实现相同的效果,但这需要在每个写入器中重复过滤。
Zend_Log_Filter_Suppress
,Zend_Log_Filter_Message
, andZend_Log_Filter_Priority
all implement theZend_Log_Filter_Interface
interface. This is denoted using the empty arrow and dotted lines between them. The same is true forZend_Log_Formatter_Interface
and the three classes depicted below it.Yes, that's correct. Whether to use an association (-->) or composition here could be debated since two
Zend_Log
instances could share a singleZend_Log_Writer_Db
instance. As the writers and filters determine the overall behavior of the log, composition makes sense to me.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 theFATAL
level. You could accomplish the same effect by dropping the log-level filter array, but it would require duplicating the filtering in each writer.