generated from pykit3/tmpl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
66 lines (42 loc) · 1.64 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
# Name
logcollector
Scan log files on local machine, collector all interested logs, and send
to somewhere for display.
# Description
We may want to see all error logs on all machines, so we need to collector
logs, and save it in somewhere. This module is used to collector logs on one
machine.
Normally, same error info will be loged repeatedly, we do not want
to save duplicated log info, so logs produced by same source file at
same line number in one second will be combined.
# Conf
configuration for log files. It is a dict, the key is the log name, the value
is the configuration for the log.
## file_path
the path of the log file.
## is_first_line
is a callback function.
The argument to this function is a line in log file, if the line is the
first line of a log, then return `True`, otherwise return `False`.
## get_level
is a callback function.
The argument to this function is the complete log string, which may contains
multiple lines. It should return the level of the log, which is a string.
## parse
is a callback function.
The argument to this function is the complete log string, which may contains
multiple lines. It should return a dict contains following fields.
- log_ts:
the timestamp of this log, such as `1523936052`, is a integer.
- level:
the level of this log, such as 'info'.
- source_file:
the source file in which the log was produced.
- line_number:
the number of the line at which the log was produced.
## level
is a list, used to specify the interested log levels.
"""
__version__ = "0.1.0"
__name__ = "k3logcollector"