I would like to log communications activity and, as part of logging, display communications history in a window on the screen. I don't want the communications modules to know about the screen of course, but any method can write to the log. The logging module then routes the information as appropriate (screen, file). Is logging considered part of the model?
Asked
Active
Viewed 1,453 times
7
-
1logging is part of controller if it logged user action activity – Stanislav Terletskyi Jun 14 '13 at 13:55
-
But it also logs communications activity. – Bruce Jun 14 '13 at 14:01
-
Please, specify "communications activity" term. I'm not sure I understand properly – Stanislav Terletskyi Jun 14 '13 at 14:22
-
@StanislavTerleckiy controller is **NOT** responsible for logging. – tereško Jun 14 '13 at 14:24
-
it depends on application needs... – Stanislav Terletskyi Jun 14 '13 at 14:32
-
Communications (in this case) through RS-232 or TCPI/IP to remote processors. – Bruce Jun 14 '13 at 14:46
-
@StanislavTerleckiy no, it does not depend on application needs. Controllers have specific responsibilities. Logging is NOT one of them. – tereško Jan 07 '14 at 12:53
1 Answers
3
Whether the commands, that are executed by instance, are logged or not should not affect the instance itself. Which means that if, for example, you want to log operation performed by controller, the controller itself should not be doing the logging or in any other way be aware that it gets logged.
The much better option is to have the instance decorated. The decorator would require the original instance and a logger injected thought constructor.
Assuming that your MVC components (views, controller and structures from mode layer) are already created via factory, this would be the best "level" at which you switch between logged and unlogged mode.
TL;DR
No. Logging is not part of MVC triad itself.