Update of "log"
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
| Artifact ID: | e5d95d497fd7e0ad9b0f6675fcfb8afc90a549b2 |
|---|---|
| Page Name: | log |
| Date: | 2015-01-06 13:40:04 |
| Original User: | mario |
| Mimetype: | text/x-markdown |
| Parent: | 2ddd84c652f81debb55cf4a1ec3f7e14322dad48 (diff) |
| Next | 8da678fa1cbd424d2473b0774bdce9a6676a9272 |
Structured and hierarchical logging with :token-parametric API
- State: experimental
- Category: logging
- Features: journaling, structured, hierarchical
- Backend: SQLite,
JSON,fluentd - Signature: hybrid, parametric
logStruck Ε implements a logging API and SQLite/JSON storage backend.
- It's purpose is storing structured log data, and it tries to retain log event hierarchies.
- Implements a hybrid and terse function interface.
- And accepts plain string messages, Ruby-style
:tokencategorizers and placeholders, and expects array structures. - Implicitly captures and maps PHP errors, unhandled exceptions, and most importantly
assert()ions.
Unlike other PHP logging frameworks it's not a primarily text/line-oriented message store.
Quick example
Basic invocations are along the lines of:
Ε(':warn', ':wikiauth', "User doesn't have permission", $pageObj, ':vars', $_SESSION);
All the fun is in the :token literals, and passing arrays or objects.
Database scheme, primary fields
All columns in the database scheme are primary fields. Any extra data/values go into the context array.
<style> table.dbstruct { width: 75%; margin-left: 5%; } table.dbstruct tr:nth-child(2n) { background: #efefef; } </style>
| i | PRIM | Where i is the primary index, g the event group, and p the parent reference. |
| g | INT | |
| p | INT | |
| timestamp | REAL | Timestamp with microseconds. |
| timestr | TEXT | ISO DateTime string. In GMT/UTC of course. |
| host | TEXT | Hostname. |
| pri | INT | Priority number (0β¦7). |
| prio | TEXT | Priority string (emergβ¦info) |
| source | TEXT | log|sys|lang|excpt|assert |
| errno | INT | 0β¦32767 |
| app | TEXT | AppName.php |
| section | TEXT | Application structure / module / part / section. |
| file | TEXT | path/file.php |
| line | INT | 125 |
| version | TEXT | Meta data from source code. |
| message | TEXT | Primary log event message string. |
| doc | TEXT | Extra documentation / long message / href. |
| backtrace | JSON | Array of :backtrace |
| code | TEXT | Extracted code context (3 lines). |
| vars | JSON | Main $vars[] array. |
| context | JSON | Additional / user-defined fields. |
| Priority levels | ||
|---|---|---|
| :debug | 7 | Low-level debug events. |
| :info | 6 | Process flow infos etc. |
| :notice, :note | 5 | Lowest priority language notices. |
| :warning, :warn | 4 | Warnings. |
| :error, :err | 3 | PHP or system error. |
| :critical, :crit | 2 | This can't be good. |
| :alert, :alrt | 1 | Turn on the bat light. |
| :emergency, :emerg | 0 | Someone call the president. |
| Source / generator | ||
| :log | Application origin, normal/manual log calls. | |
| :sys | System-level events and errno codes. | |
| :lang | Language errors, warnings, notices, etc. | |
| :exception | Langauge/runtime exceptions. | |
| :assert | Assert() warnings. | |
| Field names | ||
Any database column / primary field name can be represented as :token. It's pretty much only useful to use :vars however to map the following array parameter. | ||
| Injector calls | ||
| :backtrace | Populates backtrace. | |
| :server | Inserts $_SERVER array into context. | |
| :file | Uncovers file and line from backtrace. | |
| :version | Reads out meta data (file/scm version, and section) from script comments. | |
| :code | Inserts 3 lines of code context. | |
| :p | Tries to deduce log event hierarchy from prior calls, sections, and backtraces. (Not yet implemented.) | |
Notes / Rationale
- So, this is either genius, or completely bonkers.
- The function name Ε isn't completely settled on. (Maybe a bit too much novelty strive.)
- Extensibility of the database scheme is not planned for. (But easily done.)