You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84-63Lines changed: 84 additions & 63 deletions
Original file line number
Diff line number
Diff line change
@@ -18,12 +18,12 @@ LoggingExtras is a composable logging system.
18
18
19
19
Loggers can be broken down into 4 types:
20
20
-*Sinks*: Sinks are the final end point of a log messages journey. They write it to file, or display it on the console, or set off a red flashing light in the laboratory. A Sink should never decide what to accept, only what to do with it.
21
-
-*Filters*: Filters wrap around other loggers and decide wether or not to pass on a message. Thery can further be broken down by when that decision occurs (See `ActiveFilteredLogger` vs `EarlyFilteredLogger`).
21
+
-*Filters*: Filters wrap around other loggers and decide whether or not to pass on a message. They can further be broken down by when that decision occurs (See `ActiveFilteredLogger` vs `EarlyFilteredLogger`).
22
22
-*Transformers*: Transformers modify the content of log messages, before passing them on. This includes the metadata like severity level. Unlike Filters they can't block a log message, but they could drop its level down to say `Debug` so that normally noone would see it.
23
-
-*Demux*: There is only one possible Demux Logger. and it is central to log routing. It acts as a hub that recieves 1 log message, and then sends copies of it to all its child loggers. Like iin the diagram above, it can be composed with Filters to control what goes where.
23
+
-*Demux*: There is only one possible Demux Logger. and it is central to log routing. It acts as a hub that receives 1 log message, and then sends copies of it to all its child loggers. Like in the diagram above, it can be composed with Filters to control what goes where.
24
24
25
25
This is a basically full taxonomy of all compositional loggers.
26
-
Other than `Sinks`, this package implements the full set. So you shouldn't need to build your own routing components, just configure the ones included in this package.
26
+
This package implements the full set. So you shouldn't need to build your own routing components, just configure the ones included in this package.
27
27
28
28
It is worth understanding the idea of logging purity.
29
29
The loggers defined in this package are all pure.
@@ -81,22 +81,24 @@ logger = global_logger()
81
81
82
82
83
83
# Loggers introduced by this package:
84
-
This package introduces 7 new loggers.
85
-
The `TeeLogger`, the `TransformerLogger`, 3 types of filtered logger, and the `FileLogger`.
86
-
All of them just wrap existing loggers.
84
+
This package introduces 8 new loggers.
85
+
The `TeeLogger`, the `TransformerLogger`, 3 types of filtered logger, the `FileLogger`,
86
+
the `DatetimeRotatingFileLogger` and the `FormatLogger`.
87
+
All of them, except `FormatLogger`, just wrap existing loggers.
87
88
- The `TeeLogger` sends the logs to multiple different loggers.
88
-
- The `TransformerLogger` applies a function to modify log messages before passing them on.
89
89
- The 3 filter loggers are used to control if a message is written or not
90
-
- The `MinLevelLogger` only allowes messages to pass that are above a given level of severity
90
+
- The `MinLevelLogger` only allows messages to pass that are above a given level of severity
91
91
- The `EarlyFilteredLogger` lets you write filter rules based on the `level`, `module`, `group` and `id` of the log message
92
92
- The `ActiveFilteredLogger` lets you filter based on the full content
93
+
- The `TransformerLogger` applies a function to modify log messages before passing them on.
93
94
- The `FileLogger` is a simple logger sink that writes to file.
94
95
- The `DatetimeRotatingFileLogger` is a logger sink that writes to file, rotating logs based upon a user-provided `DateFormat`.
96
+
- The `FormatLogger` is a logger sink that simply formats the message and writes to the logger stream.
95
97
96
98
By combining `TeeLogger` with filter loggers you can arbitrarily route log messages, wherever you want.
97
99
98
100
99
-
## `TeeLogger`
101
+
## `TeeLogger` (*Demux*)
100
102
101
103
The `TeeLogger` sends the log messages to multiple places.
102
104
It takes a list of loggers.
@@ -107,53 +109,7 @@ It is up to those loggers to determine if they will accept it.
107
109
Which they do using their methods for `shouldlog` and `min_enabled_level`.
108
110
Or you can do, by wrapping them in a filtered logger as discussed below.
109
111
110
-
## `FileLogger`
111
-
The `FileLogger` does logging to file.
112
-
It is just a convience wrapper around the base julia `SimpleLogger`,
113
-
to make it easier to pass in a filename, rather than a stream.
114
-
It is really simple.
115
-
- It takes a filename,
116
-
- a kwarg to check if should `always_flush` (default: `true`).
117
-
- a kwarg to `append` rather than overwrite (default `false`. i.e. overwrite by default)
118
-
The resulting file format is similar to that which is shown in the REPL.
0 commit comments