Subversion Repositories oidplus

Rev

Rev 1209 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1209 Rev 1267
Line 1... Line 1...
1
 
1
 
2
OIDplus Logger Maskcodes
2
OIDplus Logger Mask Codes
3
========================
3
=========================
4
 
4
 
5
What is a mask code?
5
## What is a mask code?
6
--------------------
-
 
7
 
6
 
8
A "mask code" gives information about the log event.
7
A "mask code" gives information about the log event.
9
It contains:
8
It contains:
10
1. The severity (info, warning, error, critical)
9
1. The severity (info, warning, error, critical)
11
2. In which logbook(s) the event shall be placed
10
2. In which logbook(s) the event shall be placed
Line 21... Line 20...
21
- House 'B'
20
- House 'B'
22
 
21
 
23
Instead of logging into 3 logbooks separately, you would create a mask code that tells the system to put the message
22
Instead of logging into 3 logbooks separately, you would create a mask code that tells the system to put the message
24
into the logbooks of person X, house A, and house B.
23
into the logbooks of person X, house A, and house B.
25
 
24
 
26
Syntax rules
25
## Syntax rules
27
------------
-
 
28
 
26
 
29
In the code, mask codes would look like this:
27
In the code, mask codes would look like this:
30
 
28
 
31
	OIDplus::logger()->log("[INFO]OID(%1)", "RA of object '%1' changed from '%2' to '%3'", $oid, $old_ra, $new_ra);
29
	OIDplus::logger()->log("V2:[INFO]OID(%1)", "RA of object '%1' changed from '%2' to '%3'", $oid, $old_ra, $new_ra);
32
 
30
 
33
As you can see, the maskcode and message can be parameterized like `sprintf()` does,
31
As you can see, the mask code and message can be parameterized like `sprintf()` does,
34
but with the difference that `%1`, `%2`, `%3`, ..., is used instead of `%s`.
32
but with the difference that `%1`, `%2`, `%3`, ..., is used instead of `%s`.
35
 
33
 
36
Please note that the event message is not enclosed in `_L(...)`, because log-messages are always written in English,
34
Please note that the event message is not enclosed in `_L(...)`,
-
 
35
because log messages are always written in English,
37
and not in the front-end language of the user.
36
and not in the front-end language of the user.
38
 
37
 
-
 
38
### Version
-
 
39
 
-
 
40
A mask code begins with `V2:`
-
 
41
 
-
 
42
### Components
-
 
43
 
-
 
44
A mask code can have multiple components which are split into single codes using `+` or `/`, e.g. `OID(x)+RA(x)` would
-
 
45
be split to `OID(x)` and `RA(x)` which would result in the message being placed in the logbook of OID x,
-
 
46
and the logbook of the RA owning OID x.
-
 
47
 
-
 
48
### Severity
-
 
49
 
39
At the beginning of each mask code, you must define a severity, which is written in square brackets.
50
At the beginning of each mask code, you must define a severity, which is written in square brackets.
-
 
51
 
40
Valid severities:
52
Valid severities:
41
- `[OK]`: Rule of thumb: YOU have done something and it was successful.
53
- `[OK]`: Rule of thumb: YOU have done something and it was successful.
42
- `[INFO]`: Rule of thumb: Someone else has done something (that affects you) and it was successful.
54
- `[INFO]`: Rule of thumb: Someone else has done something (that affects you) and it was successful.
43
- `[WARN]`: Rule of thumb: Something happened (probably someone did something) and it affects you.
55
- `[WARN]`: Rule of thumb: Something happened (probably someone did something) and it affects you.
44
- `[ERR]`: Rule of thumb: Something failed (probably someone did something) and it affects you.
56
- `[ERR]`: Rule of thumb: Something failed (probably someone did something) and it affects you.
45
- `[CRIT]`: Rule of thumb: Something happened (probably someone did something) which is not an error, but some critical situation (e.g. hardware failure), and it affects you.
57
- `[CRIT]`: Rule of thumb: Something happened (probably someone did something) which is not an error, but some critical situation (e.g. hardware failure), and it affects you.
46
 
58
 
47
A mask code can have multiple components which are split into single codes using `+` or `/`, e.g. `OID(x)+RA(x)` would
-
 
48
be split to `OID(x)` and `RA(x)` which would result in the message being placed in the logbook of OID x,
-
 
49
and the logbook of the RA owning OID x.
-
 
50
 
-
 
51
If you have a mask code with multiple components,  you don't have to place the severity for each component.
59
If you have a mask code with multiple components, you don't have to place the severity for each component.
52
You can just leave it at the beginning. For example, `[WARN]OID(x)+RA(x)` is equal to `[WARN]OID(x)+[WARN]RA(x)`.
60
You can just leave it at the beginning. For example, `[WARN]OID(x)+RA(x)` is equal to `[WARN]OID(x)+[WARN]RA(x)`.
53
You can also put different severities for the components, e.g. `[INFO]OID(x)+[WARN]RA(x)` would be a info for the OID,
61
You can also put different severities for the components, e.g. `[INFO]OID(x)+[WARN]RA(x)`
-
 
62
would be an informative message (`INFO`) for the OID, but a warning (`WARN`) for the RA.
-
 
63
 
-
 
64
### Online/Offline dependency
-
 
65
 
-
 
66
If you want to make the logging event dependent on whether 
-
 
67
the target (`A`, `RA`, `OIDRA`, `SUPOIDRA`) matches the currently
-
 
68
logged-in user or not, write `[S1/S2]` where `S1` is the severity
-
 
69
when the logged-in user is the target
-
 
70
and `S2` is the severity when the user is not logged in or
-
 
71
logged in as a user not matching the target.
-
 
72
 
-
 
73
With this technique, you can achieve that the RA gets warned if an admin or superior RA
-
 
74
changed some of their OIDs without their knowledge,
-
 
75
but receives a success message if they did the change themselves.
-
 
76
 
-
 
77
Example: `[OK/WARN]RA(x)+[OK/INFO]A` means that there are two log messages generated:
-
 
78
- Message 1: If the currently logged-in user (performing the action)
-
 
79
is RA "x", then it is a success message (`OK`) for them,
54
but a warning for the RA.
80
otherwise it is a warning (`WARN`) for them,
-
 
81
i.e. they get warned that someone else (admin or superior RA)
-
 
82
has changed something without their knowledge.
-
 
83
- Message 2: If the currently logged-in user (performing the action)
-
 
84
is the administrator of the system, then it is a success message (`OK`)
-
 
85
for them, otherwise it is an informative message (`INFO`) for them,
-
 
86
i.e. the admin gets informed that a RA has done something.
-
 
87
 
-
 
88
You can use the special severity `NONE` to achieve that an event is
-
 
89
not logged, so `NONE/...` means that the event is not logged
-
 
90
if the currently logged-in user matches the target,
-
 
91
and `.../NONE` means that the event is not logged if the user
-
 
92
is not logged in or logged in as a user not matching the target.
55
 
93
 
-
 
94
Example: `[OK/NONE]RA(x)+[OK/NONE]A` could be used
-
 
95
to give the RA or the admin a success message (`OK`)
56
If you want to make the severity dependent on wheather the user is logged in or not,
96
for their action, but the admin won't be notified if the
57
prepend `?` or `!` and use `/` as delimiter
97
RA has changed it, and the RA won't be notified if the
58
Example: `[?WARN/!OK]RA(x)` means: If RA "x" is not logged in, it is a warning; if it is logged in, it is an success.
98
admin changed it. An Exception is if the user is logged in
59
With this technique you can achive that the RA gets warned if an admin changed some of their OIDs,
99
with both accounts (RA and admin) at the same time (which is
60
but receives an OK-Event if they did the change.
100
possible with OIDplus), then two log messages would be generated.
61
 
101
 
62
`OID(x)` means: Save the log entry into the logbook of: Object "x".
102
The severities `[NONE]` and `[NONE/NONE]` are invalid, because they are meaningless.
63
 
103
 
64
`SUPOID(x)` means: Save the log entry into the logbook of: Parent of object "x".
104
The online/offline dependency is only possible for the types `OIDRA`, `SUPOIDRA`, `RA`, and `A`,
-
 
105
but not for `OID` or `SUPOID`.
65
 
106
 
66
`OIDRA(x)!` means: Save the log entry into the logbook of: RA of object "x".
107
### Valid types
67
 
108
 
68
`OIDRA(x)?` means: Save the log entry into the logbook of: Logged in RA of object "x". If it is not logged in, nothing will be logged.
109
Besides the severity, the component has a payload in the form `Type(Value)`. 
69
 
110
 
70
`SUPOIDRA(x)!` means: Save the log entry into the logbook of: RA that owns the superior object of "x".
111
`OID(x)` means: Save the log entry into the logbook of object "x".
71
 
112
 
72
`SUPOIDRA(x)?` means: Save the log entry into the logbook of: Logged in RA that owns the superior object of "x". If it is not logged in, nothing will be logged.
113
`SUPOID(x)` means: Save the log entry into the logbook of the parent of object "x".
73
 
114
 
74
`RA(x)!` means: Save the log entry into the logbook of: RA "x".
115
`OIDRA(x)` means: Save the log entry into the logbook of the RA of object "x".
75
 
116
 
76
`RA(x)?` means: Save the log entry into the logbook of: Logged in RA "x". If it is not logged in, nothing will be logged.
117
`SUPOIDRA(x)` means: Save the log entry into the logbook of the RA that owns the superior object of "x".
77
 
118
 
78
`A!` means: Save the log entry into the logbook of: The admin.
119
`RA(x)` means: Save the log entry into the logbook of the RA "x".
79
 
120
 
80
`A?` means: Save the log entry into the logbook of: The logged in admin. If it is not logged in, nothing will be logged.
121
`A` means: Save the log entry into the logbook of the administrator of the system.
81
 
122
 
-
 
123
### Escaping
-
 
124
 
-
 
125
Inside a severity block, you can escape []/\ with \
-
 
126
 
-
 
127
Inside the value, you can escape ()+\ with \
-
 
128
 
82
Implementation
129
## Implementation
83
==============
-
 
84
 
130
 
85
You can find the implementation in **includes/classes/OIDplusLogger.class.php**.
131
You can find the implementation in **includes/classes/OIDplusLogger.class.php**.
-
 
132
 
-
 
133
## Tests
-
 
134
 
-
 
135
To check if your mask codes have the correct syntax, run the tool **dev/logger/verify_maskcodes.phps**.