]>
git.ipfire.org Git - thirdparty/systemd.git/blob - tools/catalog-report.py
2 # -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
3 # SPDX-License-Identifier: MIT
5 # This file is distributed under the MIT license, see below.
7 # The MIT License (MIT)
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"), to deal
11 # in the Software without restriction, including without limitation the rights
12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 # copies of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
16 # The above copyright notice and this permission notice shall be included in
17 # all copies or substantial portions of the Software.
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 Prints out journal entries with no or bad catalog explanations.
32 from systemd
import journal
, id128
37 pattern
= re
.compile('@[A-Z0-9_]+@')
39 mids
= {v
:k
for k
,v
in id128
.__dict__
.items()
40 if k
.startswith('SD_MESSAGE')}
46 # some of our code was using 'CODE_FUNCTION' instead of 'CODE_FUNC'
47 print('{}:{} {}'.format(x
.get('CODE_FILE', '???'),
48 x
.get('CODE_LINE', '???'),
49 x
.get('CODE_FUNC', None) or x
.get('CODE_FUNCTION', '???')))
50 print(' {}'.format(x
.get('MESSAGE', 'no message!')))
51 for k
, v
in x
.items():
52 if k
.startswith('CODE_') or k
in {'MESSAGE_ID', 'MESSAGE'}:
54 print(' {}={}'.format(k
, v
))
57 for i
, x
in enumerate(j
):
65 name
= mids
.get(mid
, 'unknown')
68 desc
= journal
.get_catalog(mid
)
69 except FileNotFoundError
:
73 print('{} {.hex}: no catalog entry'.format(name
, mid
))
78 fields
= [field
[1:-1] for field
in pattern
.findall(desc
)]
81 if field
in x
or index
in logged
:
83 print('{} {.hex}: no field {}'.format(name
, mid
, field
))