Rev 1209 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1207 | daniel-mar | 1 | |
2 | OIDplus Logger Maskcodes |
||
3 | ======================== |
||
4 | |||
5 | What is a mask code? |
||
6 | -------------------- |
||
7 | |||
8 | A "mask code" gives information about the log event. |
||
9 | It contains: |
||
10 | 1. The severity (info, warning, error, critical) |
||
11 | 2. In which logbook(s) the event shall be placed |
||
12 | |||
13 | Example: |
||
14 | Let's imagine the following event: |
||
15 | |||
16 | "Person 'X' moves from house 'A' to house 'B'" |
||
17 | |||
18 | This event would affect: |
||
19 | - Person 'X' |
||
20 | - House 'A' |
||
21 | - House 'B' |
||
22 | |||
23 | 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. |
||
25 | |||
26 | Syntax rules |
||
27 | ------------ |
||
28 | |||
29 | In the code, mask codes would look like this: |
||
30 | |||
31 | OIDplus::logger()->log("[INFO]OID(%1)", "RA of object '%1' changed from '%2' to '%3'", $oid, $old_ra, $new_ra); |
||
32 | |||
33 | As you can see, the maskcode and message can be parameterized like `sprintf()` does, |
||
34 | but with the difference that `%1`, `%2`, `%3`, ..., is used instead of `%s`. |
||
35 | |||
36 | Please note that the event message is not enclosed in `_L(...)`, because log-messages are always written in English, |
||
37 | and not in the front-end language of the user. |
||
38 | |||
39 | At the beginning of each mask code, you must define a severity, which is written in square brackets. |
||
40 | Valid severities: |
||
41 | - `[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. |
||
43 | - `[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. |
||
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. |
||
46 | |||
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. |
||
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)`. |
||
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, |
||
54 | but a warning for the RA. |
||
55 | |||
56 | If you want to make the severity dependent on wheather the user is logged in or not, |
||
57 | prepend `?` or `!` and use `/` as delimiter |
||
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. |
||
59 | With this technique you can achive that the RA gets warned if an admin changed some of their OIDs, |
||
60 | but receives an OK-Event if they did the change. |
||
61 | |||
62 | `OID(x)` means: Save the log entry into the logbook of: Object "x". |
||
63 | |||
64 | `SUPOID(x)` means: Save the log entry into the logbook of: Parent of object "x". |
||
65 | |||
66 | `OIDRA(x)!` means: Save the log entry into the logbook of: RA of object "x". |
||
67 | |||
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. |
||
69 | |||
70 | `SUPOIDRA(x)!` means: Save the log entry into the logbook of: RA that owns the superior object of "x". |
||
71 | |||
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. |
||
73 | |||
74 | `RA(x)!` means: Save the log entry into the logbook of: RA "x". |
||
75 | |||
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. |
||
77 | |||
78 | `A!` means: Save the log entry into the logbook of: The admin. |
||
79 | |||
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. |
||
81 | |||
82 | Implementation |
||
83 | ============== |
||
84 | |||
85 | You can find the implementation in `includes/classes/OIDplusLogger.class.php`. |