--- &test-RZT7
Title: Spec Example 2.28. Log File
Tags: [ header, literal, mapping, sequence, spec ]
---
Time: 2001-11-23 15:01:42 -5
User: ed
Warning:
This is an error message
for the log file
---
Time: 2001-11-23 15:02:31 -5
User: ed
Warning:
A slightly different error
message.
---
Date: 2001-11-23 15:03:17 -5
User: ed
Fatal:
Unknown variable "bar"
Stack:
- file: TopClass.py
line: 23
code: |
x = MoreObject("345\n")
- file: MoreClass.py
line: 58
code: |-
foo = bar
+STR
+DOC ---
+MAP
=VAL :Time
=VAL :2001-11-23 15:01:42 -5
=VAL :User
=VAL :ed
=VAL :Warning
=VAL :This is an error message for the log file
-MAP
-DOC
+DOC ---
+MAP
=VAL :Time
=VAL :2001-11-23 15:02:31 -5
=VAL :User
=VAL :ed
=VAL :Warning
=VAL :A slightly different error message.
-MAP
-DOC
+DOC ---
+MAP
=VAL :Date
=VAL :2001-11-23 15:03:17 -5
=VAL :User
=VAL :ed
=VAL :Fatal
=VAL :Unknown variable "bar"
=VAL :Stack
+SEQ
+MAP
=VAL :file
=VAL :TopClass.py
=VAL :line
=VAL :23
=VAL :code
=VAL |x = MoreObject("345\\n")\n
-MAP
+MAP
=VAL :file
=VAL :MoreClass.py
=VAL :line
=VAL :58
=VAL :code
=VAL |foo = bar
-MAP
-SEQ
-MAP
-DOC
-STR
{
"Time": "2001-11-23 15:01:42 -5",
"User": "ed",
"Warning": "This is an error message for the log file"
}
{
"Time": "2001-11-23 15:02:31 -5",
"User": "ed",
"Warning": "A slightly different error message."
}
{
"Date": "2001-11-23 15:03:17 -5",
"Fatal": "Unknown variable \"bar\"",
"Stack": [
{
"code": "x = MoreObject(\"345\\n\")\n",
"file": "TopClass.py",
"line": 23
},
{
"code": "foo = bar",
"file": "MoreClass.py",
"line": 58
}
],
"User": "ed"
}
json_diff
{
"Time": "2001-11-23T20:01:42.000Z",
"User": "ed",
"Warning": "This is an error message for the log file"
}
{
"Time": "2001-11-23T20:02:31.000Z",
"User": "ed",
"Warning": "A slightly different error message."
}
{
"Date": "2001-11-23T20:03:17.000Z",
"Fatal": "Unknown variable \"bar\"",
"Stack": [
{
"code": "x = MoreObject(\"345\\n\")\n",
"file": "TopClass.py",
"line": 23
},
{
"code": "foo = bar",
"file": "MoreClass.py",
"line": 58
}
],
"User": "ed"
}
json_diff
{
"Time": "2001-11-23 15:01:42 -0500",
"User": "ed",
"Warning": "This is an error message for the log file"
}
{
"Time": "2001-11-23 15:02:31 -0500",
"User": "ed",
"Warning": "A slightly different error message."
}
{
"Date": "2001-11-23 15:03:17 -0500",
"Fatal": "Unknown variable \"bar\"",
"Stack": [
{
"code": "x = MoreObject(\"345\\n\")\n",
"file": "TopClass.py",
"line": 23
},
{
"code": "foo = bar",
"file": "MoreClass.py",
"line": 58
}
],
"User": "ed"
}
error
Unhandled exception. YamlDotNet.Core.YamlException: (Line: 7, Col: 1, Idx: 97) - (Line: 7, Col: 4, Idx: 100): Expected 'StreamEnd', got 'DocumentStart' (at Line: 7, Col: 1, Idx: 97).
at YamlDotNet.Core.ParserExtensions.Require[T](IParser parser)
at YamlDotNet.Core.ParserExtensions.Consume[T](IParser parser)
at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input, Type type)
at YamlDotNet.Serialization.Deserializer.Deserialize(TextReader input)
at Program.Main(String[] commandLineArguments)
Aborted (core dumped)
error
YAML::Tiny failed to classify line ' This is an error message' at /yaml/bin/perl-tiny-json line 12.
error
YAML::Tiny failed to classify line ' This is an error message' at /yaml/bin/perl-tiny-perl line 15.
error
YAML Error: Expected separator '---'
Code: YAML_PARSE_ERR_NO_SEPARATOR
Line: 5
Document: 2
at /perl5/lib/perl5/YAML/Loader.pm line 88.
error
YAML Error: Expected separator '---'
Code: YAML_PARSE_ERR_NO_SEPARATOR
Line: 5
Document: 2
at /perl5/lib/perl5/YAML/Loader.pm line 88.
error
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
File "/yaml/bin/py-pyyaml-json", line 21, in <module>
print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.12/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
error
Error json.dumps: <class 'TypeError'>
Traceback (most recent call last):
File "/yaml/bin/py-ruamel-json", line 23, in <module>
print(json.dumps(doc, sort_keys=True, skipkeys=True, indent=2))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.12/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.12/json/encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "/usr/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable
na
Line Col Char Byte Token|Content
1 0 0 0 +DOC |
1 0 0 0 =HEAD|---
1 3 3 3 +NODE|
1 3 3 3 =EOL |\x0a
2 0 4 4 +MAP |
2 0 4 4 +PAIR|
2 0 4 4 +NODE|
2 0 4 4 +VAL |
2 0 4 4 =TEXT|Time
2 4 8 8 -VAL |
2 4 8 8 -NODE|
2 4 8 8 =SYNX|:
2 5 9 9 =WSPC|.
2 6 10 10 +NODE|
2 6 10 10 +VAL |
2 6 10 10 =TEXT|2001-11-23.15:01:42.-5
2 28 32 32 -VAL |
2 28 32 32 -NODE|
2 28 32 32 =EOL |\x0a
3 0 33 33 -PAIR|
3 0 33 33 +PAIR|
3 0 33 33 +NODE|
3 0 33 33 +VAL |
3 0 33 33 =TEXT|User
3 4 37 37 -VAL |
3 4 37 37 -NODE|
3 4 37 37 =SYNX|:
3 5 38 38 =WSPC|.
3 6 39 39 +NODE|
3 6 39 39 +VAL |
3 6 39 39 =TEXT|ed
3 8 41 41 -VAL |
3 8 41 41 -NODE|
3 8 41 41 =EOL |\x0a
4 0 42 42 -PAIR|
4 0 42 42 +PAIR|
4 0 42 42 +NODE|
4 0 42 42 +VAL |
4 0 42 42 =TEXT|Warning
4 7 49 49 -VAL |
4 7 49 49 -NODE|
4 7 49 49 =SYNX|:
4 8 50 50 =EOL |\x0a
5 0 51 51 =DENT|.
5 1 52 52 =WSPC|.
5 2 53 53 +NODE|
5 2 53 53 +VAL |
5 2 53 53 =TEXT|This.is.an.error.message
5 26 77 77 =FOLD|\x0a
6 0 78 78 =DENT|.
6 1 79 79 =WSPC|.
6 2 80 80 =TEXT|for.the.log.file
6 18 96 96 -VAL |
6 18 96 96 -NODE|
6 18 96 96 =EOL |\x0a
7 0 97 97 -PAIR|
7 0 97 97 -MAP |
7 0 97 97 -NODE|
7 0 97 97 -DOC |
7 0 97 97 +DOC |
7 0 97 97 =HEAD|---
7 3 100 100 +NODE|
7 3 100 100 =EOL |\x0a
8 0 101 101 +MAP |
8 0 101 101 +PAIR|
8 0 101 101 +NODE|
8 0 101 101 +VAL |
8 0 101 101 =TEXT|Time
8 4 105 105 -VAL |
8 4 105 105 -NODE|
8 4 105 105 =SYNX|:
8 5 106 106 =WSPC|.
8 6 107 107 +NODE|
8 6 107 107 +VAL |
8 6 107 107 =TEXT|2001-11-23.15:02:31.-5
8 28 129 129 -VAL |
8 28 129 129 -NODE|
8 28 129 129 =EOL |\x0a
9 0 130 130 -PAIR|
9 0 130 130 +PAIR|
9 0 130 130 +NODE|
9 0 130 130 +VAL |
9 0 130 130 =TEXT|User
9 4 134 134 -VAL |
9 4 134 134 -NODE|
9 4 134 134 =SYNX|:
9 5 135 135 =WSPC|.
9 6 136 136 +NODE|
9 6 136 136 +VAL |
9 6 136 136 =TEXT|ed
9 8 138 138 -VAL |
9 8 138 138 -NODE|
9 8 138 138 =EOL |\x0a
10 0 139 139 -PAIR|
10 0 139 139 +PAIR|
10 0 139 139 +NODE|
10 0 139 139 +VAL |
10 0 139 139 =TEXT|Warning
10 7 146 146 -VAL |
10 7 146 146 -NODE|
10 7 146 146 =SYNX|:
10 8 147 147 =EOL |\x0a
11 0 148 148 =DENT|.
11 1 149 149 =WSPC|.
11 2 150 150 +NODE|
11 2 150 150 +VAL |
11 2 150 150 =TEXT|A.slightly.different.error
11 28 176 176 =FOLD|\x0a
12 0 177 177 =DENT|.
12 1 178 178 =WSPC|.
12 2 179 179 =TEXT|message.
12 10 187 187 -VAL |
12 10 187 187 -NODE|
12 10 187 187 =EOL |\x0a
13 0 188 188 -PAIR|
13 0 188 188 -MAP |
13 0 188 188 -NODE|
13 0 188 188 -DOC |
13 0 188 188 +DOC |
13 0 188 188 =HEAD|---
13 3 191 191 +NODE|
13 3 191 191 =EOL |\x0a
14 0 192 192 +MAP |
14 0 192 192 +PAIR|
14 0 192 192 +NODE|
14 0 192 192 +VAL |
14 0 192 192 =TEXT|Date
14 4 196 196 -VAL |
14 4 196 196 -NODE|
14 4 196 196 =SYNX|:
14 5 197 197 =WSPC|.
14 6 198 198 +NODE|
14 6 198 198 +VAL |
14 6 198 198 =TEXT|2001-11-23.15:03:17.-5
14 28 220 220 -VAL |
14 28 220 220 -NODE|
14 28 220 220 =EOL |\x0a
15 0 221 221 -PAIR|
15 0 221 221 +PAIR|
15 0 221 221 +NODE|
15 0 221 221 +VAL |
15 0 221 221 =TEXT|User
15 4 225 225 -VAL |
15 4 225 225 -NODE|
15 4 225 225 =SYNX|:
15 5 226 226 =WSPC|.
15 6 227 227 +NODE|
15 6 227 227 +VAL |
15 6 227 227 =TEXT|ed
15 8 229 229 -VAL |
15 8 229 229 -NODE|
15 8 229 229 =EOL |\x0a
16 0 230 230 -PAIR|
16 0 230 230 +PAIR|
16 0 230 230 +NODE|
16 0 230 230 +VAL |
16 0 230 230 =TEXT|Fatal
16 5 235 235 -VAL |
16 5 235 235 -NODE|
16 5 235 235 =SYNX|:
16 6 236 236 =EOL |\x0a
17 0 237 237 =DENT|.
17 1 238 238 =WSPC|.
17 2 239 239 +NODE|
17 2 239 239 +VAL |
17 2 239 239 =TEXT|Unknown.variable."bar"
17 24 261 261 -VAL |
17 24 261 261 -NODE|
17 24 261 261 =EOL |\x0a
18 0 262 262 -PAIR|
18 0 262 262 +PAIR|
18 0 262 262 +NODE|
18 0 262 262 +VAL |
18 0 262 262 =TEXT|Stack
18 5 267 267 -VAL |
18 5 267 267 -NODE|
18 5 267 267 =SYNX|:
18 6 268 268 +NODE|
18 6 268 268 =EOL |\x0a
19 0 269 269 +SEQ |
19 0 269 269 =DENT|..
19 2 271 271 =SYNX|-
19 3 272 272 =DENT|.
19 4 273 273 +NODE|
19 4 273 273 +MAP |
19 4 273 273 +PAIR|
19 4 273 273 +NODE|
19 4 273 273 +VAL |
19 4 273 273 =TEXT|file
19 8 277 277 -VAL |
19 8 277 277 -NODE|
19 8 277 277 =SYNX|:
19 9 278 278 =WSPC|.
19 10 279 279 +NODE|
19 10 279 279 +VAL |
19 10 279 279 =TEXT|TopClass.py
19 21 290 290 -VAL |
19 21 290 290 -NODE|
19 21 290 290 =EOL |\x0a
20 0 291 291 -PAIR|
----- 8< -----
na
{
'Time' => '2001-11-23 15:01:42 -5',
'User' => 'ed',
'Warning' => 'This is an error message for the log file'
}
{
'Time' => '2001-11-23 15:02:31 -5',
'User' => 'ed',
'Warning' => 'A slightly different error message.'
}
{
'Date' => '2001-11-23 15:03:17 -5',
'Fatal' => 'Unknown variable "bar"',
'Stack' => [
{
'code' => 'x = MoreObject("345\\n")
',
'file' => 'TopClass.py',
'line' => 23
},
{
'code' => 'foo = bar',
'file' => 'MoreClass.py',
'line' => 58
}
],
'User' => 'ed'
}
na
{
'Time' => '2001-11-23 15:01:42 -5',
'User' => 'ed',
'Warning' => 'This is an error message for the log file'
}
{
'Time' => '2001-11-23 15:02:31 -5',
'User' => 'ed',
'Warning' => 'A slightly different error message.'
}
{
'Date' => '2001-11-23 15:03:17 -5',
'Fatal' => 'Unknown variable "bar"',
'Stack' => [
{
'code' => 'x = MoreObject("345\\n")
',
'file' => 'TopClass.py',
'line' => 23
},
{
'code' => 'foo = bar',
'file' => 'MoreClass.py',
'line' => 58
}
],
'User' => 'ed'
}
na
{
'Time' => '2001-11-23 15:01:42 -5',
'User' => 'ed',
'Warning' => 'This is an error message for the log file'
}
{
'Time' => '2001-11-23 15:02:31 -5',
'User' => 'ed',
'Warning' => 'A slightly different error message.'
}
{
'Date' => '2001-11-23 15:03:17 -5',
'Fatal' => 'Unknown variable "bar"',
'Stack' => [
{
'code' => 'x = MoreObject("345\\n")
',
'file' => 'TopClass.py',
'line' => 23
},
{
'code' => 'foo = bar',
'file' => 'MoreClass.py',
'line' => 58
}
],
'User' => 'ed'
}
na
{
'Time' => '2001-11-23 15:01:42 -5',
'User' => 'ed',
'Warning' => 'This is an error message for the log file'
}
{
'Time' => '2001-11-23 15:02:31 -5',
'User' => 'ed',
'Warning' => 'A slightly different error message.'
}
{
'Date' => '2001-11-23 15:03:17 -5',
'Fatal' => 'Unknown variable "bar"',
'Stack' => [
{
'code' => 'x = MoreObject("345\\n")
',
'file' => 'TopClass.py',
'line' => 23
},
{
'code' => 'foo = bar',
'file' => 'MoreClass.py',
'line' => 58
}
],
'User' => 'ed'
}
na
{'Time': datetime.datetime(2001, 11, 23, 15, 1, 42, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400))),
'User': 'ed',
'Warning': 'This is an error message for the log file'}
{'Time': datetime.datetime(2001, 11, 23, 15, 2, 31, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400))),
'User': 'ed',
'Warning': 'A slightly different error message.'}
{'Date': datetime.datetime(2001, 11, 23, 15, 3, 17, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400))),
'Fatal': 'Unknown variable "bar"',
'Stack': [{'code': 'x = MoreObject("345\\n")\n',
'file': 'TopClass.py',
'line': 23},
{'code': 'foo = bar', 'file': 'MoreClass.py', 'line': 58}],
'User': 'ed'}
na
{'Time': datetime.datetime(2001, 11, 23, 15, 1, 42, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400), '-5')),
'User': 'ed',
'Warning': 'This is an error message for the log file'}
{'Time': datetime.datetime(2001, 11, 23, 15, 2, 31, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400), '-5')),
'User': 'ed',
'Warning': 'A slightly different error message.'}
{'Date': datetime.datetime(2001, 11, 23, 15, 3, 17, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400), '-5')),
'Fatal': 'Unknown variable "bar"',
'Stack': [{'code': 'x = MoreObject("345\\n")\n',
'file': 'TopClass.py',
'line': 23},
{'code': 'foo = bar', 'file': 'MoreClass.py', 'line': 58}],
'User': 'ed'}