在探查器中创建日志的格式是什么?

发布于 2024-11-01 03:47:17 字数 341 浏览 1 评论 0原文

在我正在编写的探查器(实际上是 Java 程序的 JVMTI 代理)中,我需要一种格式来记录收集的事件。此外,这些日志必须发送到套接字并由其他地方的 GUI 读取。所以我需要两种语言之间的有效序列化。

我已经在 XML 中实现了我自己的协议,并且效果非常好。然而我被告知要考虑另一种格式。由于 XML 构建可能非常慢,并且分析器中执行的每个附加代码都会严重影响分析程序。这是事实,但是 XML DOM 构建需要那么长时间吗?

到目前为止我使用的是 TinyXML。我希望没有人指出 RapidXML,因为我希望在非嵌入式机器上没有那么不同。

你怎么认为?目前我正在尝试用protobuf重新实现它,它声称比XML快n倍。

In the profiler I am writing, which is in fact a JVMTI agent for Java programs, I need a format to log the events collected. Further these logs have to be send to a socket and read by a GUI somewhere else. So I need a working serialization between two languages.

I already implemented my own protocol in XML and it worked very well. However I was told to consider another format. As XML building might be very slow and every additional code executed in the profiler influences heavily the profiled program. This is true, but does XML DOM Building take that long?

I used TinyXML so far. I hope no one points to RapidXML, as I hope there are not that different on a not-embedded machine.

What do you think? Currently I am trying to reimplement it with protobuf, which claims to be n times faster then XML.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暗地喜欢 2024-11-08 03:47:17

我正在为我职责范围内的所有日志文件进行设计。我以 JSON 格式记录数据,但 JSON 数据嵌套在非常简单的 xml 格式中。

例如

<entry ts="2011-02-23T17:18:19.202" level="trc_1" typ="trace">New Message Received</entry>
<entry ts="2011-02-23T17:18:19.202" level="trace" typ="msg"><data>{"Name":"AgtConf","AgtId":1111,...}</data></entry>

,这样我就可以轻松地将数据和日志记录分开,但又可以避免日志记录目录变得复杂。还省去了为自定义格式编写自己的解析器的麻烦。然而,考虑到你的情况,我建议仅使用 JSON,前提是你基本上使用序列化。当格式正确时,JSON 非常适合人类可读,它可以非常简洁,并且有稳定的解析器。

I have a design I am working on for all log file in my remit. I record data in JSON but the JSON data is nested in a very simple xml format.

eg

<entry ts="2011-02-23T17:18:19.202" level="trc_1" typ="trace">New Message Received</entry>
<entry ts="2011-02-23T17:18:19.202" level="trace" typ="msg"><data>{"Name":"AgtConf","AgtId":1111,...}</data></entry>

That way I can easily separate out data and logging, but keep the logging directory from being complicated. Also saves having to write my own parser for a custom format. However given your situation I recommend using JSON only given that you are basically using to serialise. JSON is very much human-readable when it is formatted correctly, it can be very concise, and there are stable parsers for it.

街角卖回忆 2024-11-08 03:47:17

我的第一选择始终是传统的 txt 文件。

您可以在文件末尾(底部)附加新条目

my first choice is always the traditional txt file.

you can append new entries at the end of file (bottom)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文