@@ -11,8 +11,8 @@ Even multiprocessing logging becomes a breeze.
11
11
* [ Install] ( #install )
12
12
* [ Overview] ( #overview )
13
13
* [ Usage] ( #usage )
14
- * [ Overwrite the default log path] ( #- 1-overwrite-the-default-log-path )
15
- * [ Provide your config file] ( #- 2-provide-your-config-file )
14
+ * [ Overwrite the default log path] ( #1-overwrite-the-default-log-path )
15
+ * [ Provide your config file] ( #2-provide-your-config-file )
16
16
* [ Capture stdout] ( #3-capture-stdout )
17
17
* [ Exception logging] ( #4-exception-logging )
18
18
* [ try-except exception logging] ( #5-try-except-exception-logging )
@@ -152,7 +152,7 @@ Parameter with the same name passed in `setup_logging` function will override th
152
152
153
153
** Warning** : To process ` .yaml ` config file, you either need ` pyyaml ` or ` ruamel.yaml ` package installed.
154
154
155
- ###3 . Capture stdout:
155
+ ### 3. Capture stdout:
156
156
157
157
If you have an old code base with a lot of ` print(msg) ` or ` sys.stdout.write(msg) ` and
158
158
don't have access or time to refactor them into something like ` logger.info(msg) ` ,
@@ -224,7 +224,7 @@ Parameter with the same name passed in `setup_logging` function will override th
224
224
But messages that contain blank line(s) and other characters will be fully logged.
225
225
For example, ` \nTo day is a beautiful day\n ` will be logged as is.
226
226
227
- ###4 . Exception logging:
227
+ ### 4. Exception logging:
228
228
229
229
Consider the following error code snippet:
230
230
@@ -346,7 +346,7 @@ Parameter with the same name passed in `setup_logging` function will override th
346
346
If you are using python 3.8+, the new ` threading.excepthook ` won't be called as the uncaught exception
347
347
has been handled by ` logger-tt ` .
348
348
349
- ###5 . ` try-except ` exception logging:
349
+ ### 5. ` try-except ` exception logging:
350
350
351
351
` exception context ` logging also applies for ` try-except ` block.
352
352
This means that if you call ` logger.exception() ` inside ` except ` block,
@@ -396,7 +396,7 @@ Parameter with the same name passed in `setup_logging` function will override th
396
396
will cause the first line of error report to be the message of exception.
397
397
In the case of the above example, it would be come ` [2020-06-12 21:37:00] ERROR: division by zero ` .
398
398
399
- ###6 . Silent unwanted loggers:
399
+ ### 6. Silent unwanted loggers:
400
400
401
401
Third party modules also have loggers, and their messages are usually not related to your code.
402
402
A bunch of unwanted messages may hide the one that come from your own module.
@@ -436,7 +436,7 @@ Parameter with the same name passed in `setup_logging` function will override th
436
436
setup_logging(suppress = [' urllib3' , ' exchangelib' ])
437
437
```
438
438
439
- ###7 . Logging in multiprocessing:
439
+ ### 7. Logging in multiprocessing:
440
440
441
441
This is archived by using multiprocessing queues or a socket server.
442
442
@@ -501,7 +501,7 @@ Parameter with the same name passed in `setup_logging` function will override th
501
501
Other options ` True ` , ` spawn ` , ` forkserver ` will use ` socketHandler ` by default.<br >
502
502
This is to prevent you ` set_start_method ` as ` spawn ` under linux and thus ` queueHandler ` won't work.
503
503
504
- ###8 . Temporary disable logging:
504
+ ### 8. Temporary disable logging:
505
505
506
506
Some block of code contain critical information, such as password processing, that should not be logged.
507
507
You can disable logging for that block with a `logging_disabled` context:
@@ -521,7 +521,7 @@ Parameter with the same name passed in `setup_logging` function will override th
521
521
522
522
# Sample config:
523
523
Below are default config files that used by ` logger-tt ` . You can copy and modify them as needed.
524
- ##1 . Yaml format:
524
+ ## 1. Yaml format:
525
525
526
526
log_config.yaml:
527
527
@@ -580,7 +580,7 @@ Below are default config files that used by `logger-tt`. You can copy and modify
580
580
both: ["%(message)s", "%(processName)s %(threadName)s %(message)s"]
581
581
```
582
582
583
- ##2 . Json format:
583
+ ## 2. Json format:
584
584
585
585
log_config.json:
586
586
0 commit comments