你可以创建任何你想要的格式,这是首先使用 YAML 或 JSON 的主要优势。事实上,除了您自己的工作风格和个人偏好之外,没有什么能阻止您使用 YAML 或 JSON 编写所有文本文件。
### myyamllog.txt
- log_entry: posted some stuff on stack overflow
project: prj_my_personal_stuff
datestamp: 2008-11-14 07:58
summary: answering a question on formatted text for logs
body: |
you can create a "dummy" log entry as a text editor snippet
and just paste a new entry every time you start a new project.
The snippet will just contain placeholders for the parts you have
to fill in by hand. Timestamp will be auto-populated when you paste.
- log_entry: followup on SO answer
project: prj_my_personal_stuff
datestamp: 2008-11-14 08:10
summary:
body: |
As far as a "standardized" format, you can pick anything you want.
One suggestion is to just make each individual log entry a simple
series of name-value pairs. Then combine those individual entries
as a series of YAML sequence elements. The benefit of this is it
reflects the layout of a single database table. The sequence elements
are records and the name-value pairs are fields.
这样做的好处是,如果您有一个喜欢 excel 的老板,或者一个使用 HTML 的内容管理系统,那么将这种格式更改为其他输出目标格式并不难。这可能是您已经注意到的,因此您对标准格式提出了问题。
我的建议是,只需使用您想要使用的任何字段,然后将其构建为“表格”,然后找到将文本表格转换为各种不同格式的工具,如果您需要的格式不存在,请编写一个用python、perl、ruby等翻译自己。