Which design pattern would you consider when Logging is needed?

后端 未结 5 1931
悲哀的现实
悲哀的现实 2021-02-02 00:11

An application I\'m working on requires logging of actions, user who performs the action, and time of action to a database.

Which design pattern is most popular/appropri

5条回答
  •  春和景丽
    2021-02-02 01:00

    Don't conflate the Command and the logging Memento.

    The Command is something that gets done. Which may include some common aspects across all commands, including writing a log entry.

    The log entry itself may be a Memento or a summary of a Memento.

    The logger is a kind of Factory, which creates Mementos for logged events.

    As with most things, you have a large number of interlocking design patterns. Which "one" pattern is "most popular/appropriate" doesn't enter into it.

    The question is "what is supposed to be happening?"

提交回复
热议问题