0

我正在寻找扩展单用户控制台应用程序以允许访问多个用户。主要目的是让用户查看系统的状态并发出单个命令。

所有日志记录都由 python 的日志记录模块执行,该模块非常有效,因为单个用户可以指定他有兴趣在控制台中查看的日志记录级别。

但是,当涉及到允许多个用户时,我需要从简单的日志消息输出抽象到控制台。那么我的问题是,将日志记录模块的输出重定向到另一个位置的最佳方法是什么?此外,如何区分各个消息的日志级别以显示不同的用户的不同详细程度?我想我可以只解析 out 和 DEBUG/INFO 前缀,但是,当然,必须有更好的方法来“标记”单个消息。

更多细节:

  • 此时,用户在本地控制台上查看消息
  • 将来,将有更多的客户端通过基于 Web 的终端仿真与 AJAX 更新连接(因此需要更多控制)
4

1 回答 1

1

This sounds like an architectural question.

If I understand your requirements properly, what you are looking for is something like this,

  • You have a Python based system with one or more standard Python loggers writing to text file(s).
  • You need to allow several users to access this logging data in real time, using a variety of filtering techniques to control what they access.
  • Based on what they find from analysing this information, they may need to issues commands to the system to modify it's behaviour.

Given this set of requirements, I would suggest the following approach.

  • Create a centralized database to store your log records.
  • Populate the database using the standard Python logger and a custom logging handler that communicates directly from your logger to the database.
  • Develop a server based application that mediates between the web based clients and the database.
  • Use a message queue between your server logging manager and the original system to provide a transport mechanism for commands from your users to the system.

There many packages and tools that can be used to realize this scenario but I will assume that you want a primarily Python based solution and make a number of concrete suggestions.

  • Use MongoDB as your database.
  • Use MongoLog as the logging handler to interface between your original system and the MongoDB database.
  • Develop your server application in Python using Twisted as your core framework.
  • Use ZeroMQ as your message queue between your logging manager and your original system.

If you are prepared to consider using non-Python based solutions I would suggest using Meteor (a Javascript based environment) to develop both the web client environment and the logging manager.

于 2013-07-25T14:44:08.007 回答