获取其他模块的消息
我正在开发一个记录器模块,它将文本存储在文件中。在此记录器文件中,我尝试从同一项目中的其他模块接收消息。我有一个控制器,它有一些写入 shell 的输出。我不希望将此输出写入 shell,而是希望此输出能够将其发送到我的记录器模块,并且该模块随后应将输出写入文件。
问题是我应该如何编写代码来接收此消息?
谢谢
I am working on a logger module which stores text in a file. In this logger file Im trying to receive message from other modules in the same project. I have a controller that has a few outputs that is written to the shell. I don't want this output to be written to the shell instead i want this output to be able to send it to my logger module, and that module should afterwards write the output to a file.
The question is how should I write the code to receive this messages?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上没有任何进一步的详细信息,我认为您想要创建一个 事件处理程序(gen_event 行为)< /a> 非常适合日志记录、事件处理(因此得名:)等情况。
Basically without any further detailed information I would think you want to create a event handler (gen_event behaviour) which is ideal for situations as logging, event handling (hence the name :) and such.
与编写代码接收任何其他消息的方式相同;带有
receive
块。The same way you write code to receive any other message; with a
receive
block.