-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
logging.po
2256 lines (1935 loc) · 108 KB
/
logging.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2024, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Yan Gao <gao.yan.gg1994@gmail.com>, 2018
# Alpha Du <alphanow@gmail.com>, 2019
# MuSheng Chen <sheng.2179@gmail.com>, 2019
# Zombie110year <zombie110year@gmail.com>, 2019
# 1lin24 <1lin24@sina.com>, 2019
# Shengjing Zhu <zsj950618@gmail.com>, 2019
# ppcfish <ppcfish@gmail.com>, 2019
# Leo Li <foxleoly@hotmail.com>, 2020
# jaystone776 <1732865113@qq.com>, 2021
# Freesand Leo <yuqinju@163.com>, 2021
# WH-2099 <wh2099@outlook.com>, 2022
# Rafael Fontenelle <rffontenelle@gmail.com>, 2024
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.9\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-12 22:01+0000\n"
"PO-Revision-Date: 2017-02-16 23:17+0000\n"
"Last-Translator: Rafael Fontenelle <rffontenelle@gmail.com>, 2024\n"
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../library/logging.rst:2
msgid ":mod:`logging` --- Logging facility for Python"
msgstr ":mod:`logging` --- Python 的日志记录工具"
#: ../../library/logging.rst:10
msgid "**Source code:** :source:`Lib/logging/__init__.py`"
msgstr "**源代码:** :source:`Lib/logging/__init__.py`"
#: ../../library/logging.rst:16
msgid ""
"This page contains the API reference information. For tutorial information "
"and discussion of more advanced topics, see"
msgstr "此页面仅包含 API 参考信息。教程信息和更多高级用法的讨论,请参阅"
#: ../../library/logging.rst:19
msgid ":ref:`Basic Tutorial <logging-basic-tutorial>`"
msgstr ":ref:`基础教程 <logging-basic-tutorial>`"
#: ../../library/logging.rst:20
msgid ":ref:`Advanced Tutorial <logging-advanced-tutorial>`"
msgstr ":ref:`进阶教程 <logging-advanced-tutorial>`"
#: ../../library/logging.rst:21
msgid ":ref:`Logging Cookbook <logging-cookbook>`"
msgstr ":ref:`日志记录操作手册 <logging-cookbook>`"
#: ../../library/logging.rst:25
msgid ""
"This module defines functions and classes which implement a flexible event "
"logging system for applications and libraries."
msgstr "这个模块为应用与库实现了灵活的事件日志系统的函数与类。"
#: ../../library/logging.rst:28
msgid ""
"The key benefit of having the logging API provided by a standard library "
"module is that all Python modules can participate in logging, so your "
"application log can include your own messages integrated with messages from "
"third-party modules."
msgstr ""
"使用标准库提供的 logging API 最主要的好处是,所有的 Python 模块都可能参与日志输出,包括你自己的日志消息和第三方模块的日志消息。"
#: ../../library/logging.rst:33
msgid ""
"The module provides a lot of functionality and flexibility. If you are "
"unfamiliar with logging, the best way to get to grips with it is to see the "
"tutorials (see the links on the right)."
msgstr "这个模块提供许多强大而灵活的功能。如果对 logging 不太熟悉, 掌握它最好的方式就是查看它对应的教程(详见右侧的链接)。"
#: ../../library/logging.rst:37
msgid ""
"The basic classes defined by the module, together with their functions, are "
"listed below."
msgstr "该模块定义的基础类和函数都列在下面。"
#: ../../library/logging.rst:40
msgid "Loggers expose the interface that application code directly uses."
msgstr "记录器暴露了应用程序代码直接使用的接口。"
#: ../../library/logging.rst:41
msgid ""
"Handlers send the log records (created by loggers) to the appropriate "
"destination."
msgstr "处理器将日志记录(由记录器创建)发送到适当的目标。"
#: ../../library/logging.rst:43
msgid ""
"Filters provide a finer grained facility for determining which log records "
"to output."
msgstr "过滤器提供了更细粒度的功能,用于确定要输出的日志记录。"
#: ../../library/logging.rst:45
msgid "Formatters specify the layout of log records in the final output."
msgstr "格式器指定最终输出中日志记录的样式。"
#: ../../library/logging.rst:51
msgid "Logger Objects"
msgstr "记录器对象"
#: ../../library/logging.rst:53
msgid ""
"Loggers have the following attributes and methods. Note that Loggers should"
" *NEVER* be instantiated directly, but always through the module-level "
"function ``logging.getLogger(name)``. Multiple calls to :func:`getLogger` "
"with the same name will always return a reference to the same Logger object."
msgstr ""
"记录器有以下的属性和方法。注意 *永远* 不要直接实例化记录器,应当通过模块级别的函数 ``logging.getLogger(name)`` "
"。多次使用相同的名字调用 :func:`getLogger` 会一直返回相同的 Logger 对象的引用。"
#: ../../library/logging.rst:58
msgid ""
"The ``name`` is potentially a period-separated hierarchical value, like "
"``foo.bar.baz`` (though it could also be just plain ``foo``, for example). "
"Loggers that are further down in the hierarchical list are children of "
"loggers higher up in the list. For example, given a logger with a name of "
"``foo``, loggers with names of ``foo.bar``, ``foo.bar.baz``, and ``foo.bam``"
" are all descendants of ``foo``. The logger name hierarchy is analogous to "
"the Python package hierarchy, and identical to it if you organise your "
"loggers on a per-module basis using the recommended construction "
"``logging.getLogger(__name__)``. That's because in a module, ``__name__`` "
"is the module's name in the Python package namespace."
msgstr ""
"``name`` 一般是句点分割的层级值, 像 ``foo.bar.baz`` (尽管也可以只是普通的 "
"``foo``)。层次结构列表中位于下方的记录器是列表中较高位置的记录器的子级。例如,有个名叫 ``foo`` 的记录器,而名字是 "
"``foo.bar``, ``foo.bar.baz``,和 ``foo.bam`` 的记录器都是 ``foo`` 的子级。记录器的名字分级类似 "
"Python 包的层级,如果您使用建议的结构 ``logging.getLogger(__name__)`` "
"在每个模块的基础上组织记录器,则与之完全相同。这是因为在模块里, ``__name__`` 是该模块在 Python 包命名空间中的名字。"
#: ../../library/logging.rst:74
msgid ""
"If this attribute evaluates to true, events logged to this logger will be "
"passed to the handlers of higher level (ancestor) loggers, in addition to "
"any handlers attached to this logger. Messages are passed directly to the "
"ancestor loggers' handlers - neither the level nor filters of the ancestor "
"loggers in question are considered."
msgstr ""
"如果这个属性为真,记录到这个记录器的事件除了会发送到此记录器的所有处理程序外,还会传递给更高级别(祖先)记录器的处理器,此外任何关联到这个记录器的处理器。消息会直接传递给祖先记录器的处理器"
" —— 不考虑祖先记录器的级别和过滤器。"
#: ../../library/logging.rst:80
msgid ""
"If this evaluates to false, logging messages are not passed to the handlers "
"of ancestor loggers."
msgstr "如果为假,记录消息将不会传递给当前记录器的祖先记录器的处理器。"
#: ../../library/logging.rst:83
msgid ""
"Spelling it out with an example: If the propagate attribute of the logger "
"named ``A.B.C`` evaluates to true, any event logged to ``A.B.C`` via a "
"method call such as ``logging.getLogger('A.B.C').error(...)`` will [subject "
"to passing that logger's level and filter settings] be passed in turn to any"
" handlers attached to loggers named ``A.B``, ``A`` and the root logger, "
"after first being passed to any handlers attached to ``A.B.C``. If any "
"logger in the chain ``A.B.C``, ``A.B``, ``A`` has its ``propagate`` "
"attribute set to false, then that is the last logger whose handlers are "
"offered the event to handle, and propagation stops at that point."
msgstr ""
"举例说明:如果名为 ``A.B.C`` 的记录器的传播属性求值为真,则任何通过调用诸如 "
"``logging.getLogger('A.B.C').error(...)`` 之类的方法记录到 ``A.B.C`` 的事件,在第一次被传递到 "
"``A.B.C`` 上附加的处理器后,将[取决于传递该记录器的级别和过滤器设置]依次传递给附加到名为 ``A.B``,``A`` "
"的记录器和根记录器的所有处理器。如果 ``A.B.C``、``A.B``、``A`` 组成的链中,任一记录器的 ``propagate`` "
"属性设置为假,那么这将是最后一个其处理器会收到事件的记录器,此后传播在该点停止。"
#: ../../library/logging.rst:92
msgid "The constructor sets this attribute to ``True``."
msgstr "构造器将这个属性初始化为 ``True``。"
#: ../../library/logging.rst:94
msgid ""
"If you attach a handler to a logger *and* one or more of its ancestors, it "
"may emit the same record multiple times. In general, you should not need to "
"attach a handler to more than one logger - if you just attach it to the "
"appropriate logger which is highest in the logger hierarchy, then it will "
"see all events logged by all descendant loggers, provided that their "
"propagate setting is left set to ``True``. A common scenario is to attach "
"handlers only to the root logger, and to let propagation take care of the "
"rest."
msgstr ""
"如果你将一个处理器附加到一个记录器 *和* 其一个或多个祖先记录器,它可能发出多次相同的记录。通常,您不需要将一个处理器附加到一个以上的记录器上 —— "
"如果您将它附加到记录器层次结构中最高的适当记录器上,则它将看到所有后代记录器记录的所有事件,前提是它们的传播设置保留为 "
"``True``。一种常见的方案是仅将处理器附加到根记录器,通过传播来处理其余部分。"
#: ../../library/logging.rst:105
msgid ""
"Sets the threshold for this logger to *level*. Logging messages which are "
"less severe than *level* will be ignored; logging messages which have "
"severity *level* or higher will be emitted by whichever handler or handlers "
"service this logger, unless a handler's level has been set to a higher "
"severity level than *level*."
msgstr ""
"给记录器设置阈值为 *level* 。日志等级小于 *level* 会被忽略。严重性为 *level* "
"或更高的日志消息将由该记录器的任何一个或多个处理器发出,除非将处理器的级别设置为比 *level* 更高的级别。"
#: ../../library/logging.rst:110
msgid ""
"When a logger is created, the level is set to :const:`NOTSET` (which causes "
"all messages to be processed when the logger is the root logger, or "
"delegation to the parent when the logger is a non-root logger). Note that "
"the root logger is created with level :const:`WARNING`."
msgstr ""
"创建记录器时,级别默认设置为 :const:`NOTSET` "
"(当记录器是根记录器时,将处理所有消息;如果记录器不是根记录器,则将委托给父级)。请注意,根记录器的默认级别为 :const:`WARNING` 。"
#: ../../library/logging.rst:115
msgid ""
"The term 'delegation to the parent' means that if a logger has a level of "
"NOTSET, its chain of ancestor loggers is traversed until either an ancestor "
"with a level other than NOTSET is found, or the root is reached."
msgstr ""
"委派给父级的意思是如果一个记录器的级别设置为 NOTSET,将遍历其祖先记录器,直到找到级别不是 NOTSET 的记录器,或者到根记录器为止。"
#: ../../library/logging.rst:119
msgid ""
"If an ancestor is found with a level other than NOTSET, then that ancestor's"
" level is treated as the effective level of the logger where the ancestor "
"search began, and is used to determine how a logging event is handled."
msgstr "如果发现某个父级的级别不是 NOTSET ,那么该父级的级别将被视为发起搜索的记录器的有效级别,并用于确定如何处理日志事件。"
#: ../../library/logging.rst:123
msgid ""
"If the root is reached, and it has a level of NOTSET, then all messages will"
" be processed. Otherwise, the root's level will be used as the effective "
"level."
msgstr "如果搜索到达根记录器,并且其级别为 NOTSET,则将处理所有消息。否则,将使用根记录器的级别作为有效级别。"
#: ../../library/logging.rst:126 ../../library/logging.rst:435
msgid "See :ref:`levels` for a list of levels."
msgstr "参见 :ref:`levels` 级别列表。"
#: ../../library/logging.rst:128
msgid ""
"The *level* parameter now accepts a string representation of the level such "
"as 'INFO' as an alternative to the integer constants such as :const:`INFO`. "
"Note, however, that levels are internally stored as integers, and methods "
"such as e.g. :meth:`getEffectiveLevel` and :meth:`isEnabledFor` will "
"return/expect to be passed integers."
msgstr ""
"现在 *level* 参数可以接受形如 'INFO' 的级别字符串表示形式,以代替形如 :const:`INFO` 的整数常量。 "
"但是请注意,级别在内部存储为整数,并且 :meth:`getEffectiveLevel` 和 :meth:`isEnabledFor` "
"等方法的传入/返回值也为整数。"
#: ../../library/logging.rst:138
msgid ""
"Indicates if a message of severity *level* would be processed by this "
"logger. This method checks first the module-level level set by "
"``logging.disable(level)`` and then the logger's effective level as "
"determined by :meth:`getEffectiveLevel`."
msgstr ""
"指示此记录器是否将处理级别为 *level* 的消息。此方法首先检查由 ``logging.disable(level)`` "
"设置的模块级的级别,然后检查由 :meth:`getEffectiveLevel` 确定的记录器的有效级别。"
#: ../../library/logging.rst:146
msgid ""
"Indicates the effective level for this logger. If a value other than "
":const:`NOTSET` has been set using :meth:`setLevel`, it is returned. "
"Otherwise, the hierarchy is traversed towards the root until a value other "
"than :const:`NOTSET` is found, and that value is returned. The value "
"returned is an integer, typically one of :const:`logging.DEBUG`, "
":const:`logging.INFO` etc."
msgstr ""
"指示此记录器的有效级别。如果通过 :meth:`setLevel` 设置了除 :const:`NOTSET` "
"以外的值,则返回该值。否则,将层次结构遍历到根,直到找到除 :const:`NOTSET` 以外的其他值,然后返回该值。返回的值是一个整数,通常为 "
":const:`logging.DEBUG`、 :const:`logging.INFO` 等等。"
#: ../../library/logging.rst:156
msgid ""
"Returns a logger which is a descendant to this logger, as determined by the "
"suffix. Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return "
"the same logger as would be returned by "
"``logging.getLogger('abc.def.ghi')``. This is a convenience method, useful "
"when the parent logger is named using e.g. ``__name__`` rather than a "
"literal string."
msgstr ""
"返回由后缀确定的该记录器的后代记录器。 因此,``logging.getLogger('abc').getChild('def.ghi')`` 与 "
"``logging.getLogger('abc.def.ghi')`` 将返回相同的记录器。 这是一个便捷方法,当使用如 ``__name__`` "
"而不是字符串字面值命名父记录器时很有用。"
#: ../../library/logging.rst:167
msgid ""
"Logs a message with level :const:`DEBUG` on this logger. The *msg* is the "
"message format string, and the *args* are the arguments which are merged "
"into *msg* using the string formatting operator. (Note that this means that "
"you can use keywords in the format string, together with a single dictionary"
" argument.) No % formatting operation is performed on *msg* when no *args* "
"are supplied."
msgstr ""
"在此记录器上记录 :const:`DEBUG` 级别的消息。 *msg* 是消息格式字符串,而 *args* 是用于字符串格式化操作合并到 *msg* "
"的参数。(请注意,这意味着您可以在格式字符串中使用关键字以及单个字典参数。)当未提供 *args* 时,不会对 *msg* 执行 % 格式化操作。"
#: ../../library/logging.rst:173
msgid ""
"There are four keyword arguments in *kwargs* which are inspected: "
"*exc_info*, *stack_info*, *stacklevel* and *extra*."
msgstr ""
"在 *kwargs* 中会检查四个关键字参数: *exc_info* ,*stack_info* ,*stacklevel* 和 *extra* 。"
#: ../../library/logging.rst:176
msgid ""
"If *exc_info* does not evaluate as false, it causes exception information to"
" be added to the logging message. If an exception tuple (in the format "
"returned by :func:`sys.exc_info`) or an exception instance is provided, it "
"is used; otherwise, :func:`sys.exc_info` is called to get the exception "
"information."
msgstr ""
"如果 *exc_info* 的求值结果不为 false ,则它将异常信息添加到日志消息中。如果提供了一个异常元组(按照 "
":func:`sys.exc_info` 返回的格式)或一个异常实例,则它将被使用;否则,调用 :func:`sys.exc_info` "
"以获取异常信息。"
#: ../../library/logging.rst:181 ../../library/logging.rst:979
msgid ""
"The second optional keyword argument is *stack_info*, which defaults to "
"``False``. If true, stack information is added to the logging message, "
"including the actual logging call. Note that this is not the same stack "
"information as that displayed through specifying *exc_info*: The former is "
"stack frames from the bottom of the stack up to the logging call in the "
"current thread, whereas the latter is information about stack frames which "
"have been unwound, following an exception, while searching for exception "
"handlers."
msgstr ""
"第二个可选关键字参数是 *stack_info*,默认为 ``False``。如果为 "
"True,则将堆栈信息添加到日志消息中,包括实际的日志调用。请注意,这与通过指定 *exc_info* "
"显示的堆栈信息不同:前者是从堆栈底部到当前线程中的日志记录调用的堆栈帧,而后者是在搜索异常处理程序时,跟踪异常而打开的堆栈帧的信息。"
#: ../../library/logging.rst:190 ../../library/logging.rst:988
msgid ""
"You can specify *stack_info* independently of *exc_info*, e.g. to just show "
"how you got to a certain point in your code, even when no exceptions were "
"raised. The stack frames are printed following a header line which says:"
msgstr ""
"您可以独立于 *exc_info* 来指定 "
"*stack_info*,例如,即使在未引发任何异常的情况下,也可以显示如何到达代码中的特定点。堆栈帧在标题行之后打印:"
#: ../../library/logging.rst:198 ../../library/logging.rst:996
msgid ""
"This mimics the ``Traceback (most recent call last):`` which is used when "
"displaying exception frames."
msgstr "这模仿了显示异常帧时所使用的 ``Traceback (most recent call last):`` 。"
#: ../../library/logging.rst:201
msgid ""
"The third optional keyword argument is *stacklevel*, which defaults to "
"``1``. If greater than 1, the corresponding number of stack frames are "
"skipped when computing the line number and function name set in the "
":class:`LogRecord` created for the logging event. This can be used in "
"logging helpers so that the function name, filename and line number recorded"
" are not the information for the helper function/method, but rather its "
"caller. The name of this parameter mirrors the equivalent one in the "
":mod:`warnings` module."
msgstr ""
"第三个可选关键字参数是 *stacklevel* ,默认为 ``1`` 。如果大于 1 ,则在为日志记录事件创建的 :class:`LogRecord`"
" "
"中计算行号和函数名时,将跳过相应数量的堆栈帧。可以在记录帮助器时使用它,以便记录的函数名称,文件名和行号不是帮助器的函数/方法的信息,而是其调用方的信息。此参数是"
" :mod:`warnings` 模块中的同名等效参数。"
#: ../../library/logging.rst:209
msgid ""
"The fourth keyword argument is *extra* which can be used to pass a "
"dictionary which is used to populate the __dict__ of the :class:`LogRecord` "
"created for the logging event with user-defined attributes. These custom "
"attributes can then be used as you like. For example, they could be "
"incorporated into logged messages. For example::"
msgstr ""
"第四个关键字参数是 *extra* ,传递一个字典,该字典用于填充为日志记录事件创建的、带有用户自定义属性的 :class:`LogRecord` 中的"
" __dict__ 。然后可以按照需求使用这些自定义属性。例如,可以将它们合并到已记录的消息中:"
#: ../../library/logging.rst:221
msgid "would print something like"
msgstr "输出类似于"
#: ../../library/logging.rst:227 ../../library/logging.rst:1016
msgid ""
"The keys in the dictionary passed in *extra* should not clash with the keys "
"used by the logging system. (See the :class:`Formatter` documentation for "
"more information on which keys are used by the logging system.)"
msgstr ""
"*extra* 中传入的字典的键不应与日志系统使用的键冲突。(有关日志系统使用哪些键的更多信息,请参见 :class:`Formatter` 的文档。)"
#: ../../library/logging.rst:231
msgid ""
"If you choose to use these attributes in logged messages, you need to "
"exercise some care. In the above example, for instance, the "
":class:`Formatter` has been set up with a format string which expects "
"'clientip' and 'user' in the attribute dictionary of the :class:`LogRecord`."
" If these are missing, the message will not be logged because a string "
"formatting exception will occur. So in this case, you always need to pass "
"the *extra* dictionary with these keys."
msgstr ""
"如果在已记录的消息中使用这些属性,则需要格外小心。例如,在上面的示例中,:class:`Formatter` 已设置了格式字符串,其在 "
":class:`LogRecord` 的属性字典中键值为 “clientip” 和 "
"“user”。如果缺少这些内容,则将不会记录该消息,因为会引发字符串格式化异常。因此,在这种情况下,您始终需要使用 *extra* 字典传递这些键。"
#: ../../library/logging.rst:238 ../../library/logging.rst:1027
msgid ""
"While this might be annoying, this feature is intended for use in "
"specialized circumstances, such as multi-threaded servers where the same "
"code executes in many contexts, and interesting conditions which arise are "
"dependent on this context (such as remote client IP address and "
"authenticated user name, in the above example). In such circumstances, it is"
" likely that specialized :class:`Formatter`\\ s would be used with "
"particular :class:`Handler`\\ s."
msgstr ""
"尽管这可能很烦人,但此功能旨在用于特殊情况,例如在多个上下文中执行相同代码的多线程服务器,并且出现的有趣条件取决于此上下文(例如在上面的示例中就是远程客户端IP地址和已验证用户名)。在这种情况下,很可能将专门的"
" :class:`Formatter` 与特定的 :class:`Handler` 一起使用。"
#: ../../library/logging.rst:245 ../../library/logging.rst:1034
msgid "The *stack_info* parameter was added."
msgstr "增加了 *stack_info* 参数。"
#: ../../library/logging.rst:248
msgid "The *exc_info* parameter can now accept exception instances."
msgstr "*exc_info* 参数现在可以接受异常实例。"
#: ../../library/logging.rst:251
msgid "The *stacklevel* parameter was added."
msgstr "增加了 *stacklevel* 参数。"
#: ../../library/logging.rst:257
msgid ""
"Logs a message with level :const:`INFO` on this logger. The arguments are "
"interpreted as for :meth:`debug`."
msgstr "在此记录器上记录 :const:`INFO` 级别的消息。参数解释同 :meth:`debug`。"
#: ../../library/logging.rst:263
msgid ""
"Logs a message with level :const:`WARNING` on this logger. The arguments are"
" interpreted as for :meth:`debug`."
msgstr "在此记录器上记录 :const:`WARNING` 级别的消息。参数解释同 :meth:`debug`。"
#: ../../library/logging.rst:266
msgid ""
"There is an obsolete method ``warn`` which is functionally identical to "
"``warning``. As ``warn`` is deprecated, please do not use it - use "
"``warning`` instead."
msgstr ""
"有一个功能上与 ``warning`` 一致的方法 ``warn``。由于 ``warn`` 已被弃用,请不要使用它 —— 改为使用 "
"``warning``。"
#: ../../library/logging.rst:272
msgid ""
"Logs a message with level :const:`ERROR` on this logger. The arguments are "
"interpreted as for :meth:`debug`."
msgstr "在此记录器上记录 :const:`ERROR` 级别的消息。参数解释同 :meth:`debug`。"
#: ../../library/logging.rst:278
msgid ""
"Logs a message with level :const:`CRITICAL` on this logger. The arguments "
"are interpreted as for :meth:`debug`."
msgstr "在此记录器上记录 :const:`CRITICAL` 级别的消息。参数解释同 :meth:`debug`。"
#: ../../library/logging.rst:284
msgid ""
"Logs a message with integer level *level* on this logger. The other "
"arguments are interpreted as for :meth:`debug`."
msgstr "在此记录器上记录 *level* 整数代表的级别的消息。参数解释同 :meth:`debug`。"
#: ../../library/logging.rst:290
msgid ""
"Logs a message with level :const:`ERROR` on this logger. The arguments are "
"interpreted as for :meth:`debug`. Exception info is added to the logging "
"message. This method should only be called from an exception handler."
msgstr ""
"在此记录器上记录 :const:`ERROR` 级别的消息。参数解释同 "
":meth:`debug`。异常信息将添加到日志消息中。仅应从异常处理程序中调用此方法。"
#: ../../library/logging.rst:297
msgid "Adds the specified filter *filter* to this logger."
msgstr "将指定的过滤器 *filter* 添加到此记录器。"
#: ../../library/logging.rst:302
msgid "Removes the specified filter *filter* from this logger."
msgstr "从此记录器中删除指定的过滤器 *filter*。"
#: ../../library/logging.rst:307
msgid ""
"Apply this logger's filters to the record and return ``True`` if the record "
"is to be processed. The filters are consulted in turn, until one of them "
"returns a false value. If none of them return a false value, the record will"
" be processed (passed to handlers). If one returns a false value, no further"
" processing of the record occurs."
msgstr ""
"将此记录器的过滤器应用于记录,如果记录能被处理则返回 "
"``True``。过滤器会被依次使用,直到其中一个返回假值为止。如果它们都不返回假值,则记录将被处理(传递给处理器)。如果返回任一为假值,则不会对该记录做进一步处理。"
#: ../../library/logging.rst:316
msgid "Adds the specified handler *hdlr* to this logger."
msgstr "将指定的处理器 *hdlr* 添加到此记录器。"
#: ../../library/logging.rst:321
msgid "Removes the specified handler *hdlr* from this logger."
msgstr "从此记录器中删除指定的处理器 *hdlr*。"
#: ../../library/logging.rst:326
msgid ""
"Finds the caller's source filename and line number. Returns the filename, "
"line number, function name and stack information as a 4-element tuple. The "
"stack information is returned as ``None`` unless *stack_info* is ``True``."
msgstr ""
"查找调用源的文件名和行号,以 文件名,行号,函数名称和堆栈信息 4元素元组的形式返回。堆栈信息将返回 ``None``,除非 *stack_info* "
"为 ``True``。"
#: ../../library/logging.rst:330
msgid ""
"The *stacklevel* parameter is passed from code calling the :meth:`debug` and"
" other APIs. If greater than 1, the excess is used to skip stack frames "
"before determining the values to be returned. This will generally be useful "
"when calling logging APIs from helper/wrapper code, so that the information "
"in the event log refers not to the helper/wrapper code, but to the code that"
" calls it."
msgstr ""
"*stacklevel* 参数用于调用 :meth:`debug` 和其他 API。如果大于 "
"1,则多余部分将用于跳过堆栈帧,然后再确定要返回的值。当从帮助器/包装器代码调用日志记录 API "
"时,这通常很有用,以便事件日志中的信息不是来自帮助器/包装器代码,而是来自调用它的代码。"
#: ../../library/logging.rst:340
msgid ""
"Handles a record by passing it to all handlers associated with this logger "
"and its ancestors (until a false value of *propagate* is found). This method"
" is used for unpickled records received from a socket, as well as those "
"created locally. Logger-level filtering is applied using "
":meth:`~Logger.filter`."
msgstr ""
"通过将记录传递给与此记录器及其祖先关联的所有处理器来处理(直到某个 *propagate* 值为 "
"false)。此方法用于从套接字接收的未序列化的以及在本地创建的记录。使用 :meth:`~Logger.filter` 进行记录器级别过滤。"
#: ../../library/logging.rst:348
msgid ""
"This is a factory method which can be overridden in subclasses to create "
"specialized :class:`LogRecord` instances."
msgstr "这是一种工厂方法,可以在子类中对其进行重写以创建专门的 :class:`LogRecord` 实例。"
#: ../../library/logging.rst:353
msgid ""
"Checks to see if this logger has any handlers configured. This is done by "
"looking for handlers in this logger and its parents in the logger hierarchy."
" Returns ``True`` if a handler was found, else ``False``. The method stops "
"searching up the hierarchy whenever a logger with the 'propagate' attribute "
"set to false is found - that will be the last logger which is checked for "
"the existence of handlers."
msgstr ""
"检查此记录器是否配置了任何处理器。通过在此记录器及其记录器层次结构中的父级中查找处理器完成此操作。如果找到处理器则返回 ``True``,否则返回 "
"``False``。只要找到 “propagate” 属性设置为假值的记录器,该方法就会停止搜索层次结构 —— "
"其将是最后一个检查处理器是否存在的记录器。"
#: ../../library/logging.rst:362
msgid "Loggers can now be pickled and unpickled."
msgstr "现在可以对处理器进行序列化和反序列化。"
#: ../../library/logging.rst:368
msgid "Logging Levels"
msgstr "日志级别"
#: ../../library/logging.rst:370
msgid ""
"The numeric values of logging levels are given in the following table. These"
" are primarily of interest if you want to define your own levels, and need "
"them to have specific values relative to the predefined levels. If you "
"define a level with the same numeric value, it overwrites the predefined "
"value; the predefined name is lost."
msgstr ""
"日志记录级别的数值在下表中给出。如果你想要定义自己的级别,并且需要它们具有相对于预定义级别的特定值,那么这你可能对以下内容感兴趣。如果你定义具有相同数值的级别,它将覆盖预定义的值;预定义的名称将失效。"
#: ../../library/logging.rst:377
msgid "Level"
msgstr "级别"
#: ../../library/logging.rst:377
msgid "Numeric value"
msgstr "数值"
#: ../../library/logging.rst:379
msgid "``CRITICAL``"
msgstr "``CRITICAL``"
#: ../../library/logging.rst:379
msgid "50"
msgstr "50"
#: ../../library/logging.rst:381
msgid "``ERROR``"
msgstr "``ERROR``"
#: ../../library/logging.rst:381
msgid "40"
msgstr "40"
#: ../../library/logging.rst:383
msgid "``WARNING``"
msgstr "``WARNING``"
#: ../../library/logging.rst:383
msgid "30"
msgstr "30"
#: ../../library/logging.rst:385
msgid "``INFO``"
msgstr "``INFO``"
#: ../../library/logging.rst:385
msgid "20"
msgstr "20"
#: ../../library/logging.rst:387
msgid "``DEBUG``"
msgstr "``DEBUG``"
#: ../../library/logging.rst:387
msgid "10"
msgstr "10"
#: ../../library/logging.rst:389
msgid "``NOTSET``"
msgstr "``NOTSET``"
#: ../../library/logging.rst:389
msgid "0"
msgstr "0"
#: ../../library/logging.rst:396
msgid "Handler Objects"
msgstr "处理器对象"
#: ../../library/logging.rst:398
msgid ""
"Handlers have the following attributes and methods. Note that "
":class:`Handler` is never instantiated directly; this class acts as a base "
"for more useful subclasses. However, the :meth:`__init__` method in "
"subclasses needs to call :meth:`Handler.__init__`."
msgstr ""
"Handler 有以下属性和方法。注意不要直接实例化 :class:`Handler` ;这个类用来派生其他更有用的子类。但是,子类的 "
":meth:`__init__` 方法需要调用 :meth:`Handler.__init__` 。"
#: ../../library/logging.rst:407
msgid ""
"Initializes the :class:`Handler` instance by setting its level, setting the "
"list of filters to the empty list and creating a lock (using "
":meth:`createLock`) for serializing access to an I/O mechanism."
msgstr ""
"初始化 :class:`Handler` 实例时,需要设置它的级别,将过滤列表置为空,并且创建锁(通过 :meth:`createLock` "
")来序列化对 I/O 的访问。"
#: ../../library/logging.rst:414
msgid ""
"Initializes a thread lock which can be used to serialize access to "
"underlying I/O functionality which may not be threadsafe."
msgstr "初始化一个线程锁,用来序列化对底层的 I/O 功能的访问,底层的 I/O 功能可能不是线程安全的。"
#: ../../library/logging.rst:420
msgid "Acquires the thread lock created with :meth:`createLock`."
msgstr "获取由 :meth:`createLock` 创建的线程锁。"
#: ../../library/logging.rst:425
msgid "Releases the thread lock acquired with :meth:`acquire`."
msgstr "释放由 :meth:`acquire` 获取的线程锁。"
#: ../../library/logging.rst:430
msgid ""
"Sets the threshold for this handler to *level*. Logging messages which are "
"less severe than *level* will be ignored. When a handler is created, the "
"level is set to :const:`NOTSET` (which causes all messages to be processed)."
msgstr ""
"给处理器设置阈值为 *level* 。日志级别小于 *level* 将被忽略。创建处理器时,日志级别被设置为 :const:`NOTSET` "
"(所有的消息都会被处理)。"
#: ../../library/logging.rst:437
msgid ""
"The *level* parameter now accepts a string representation of the level such "
"as 'INFO' as an alternative to the integer constants such as :const:`INFO`."
msgstr "*level* 形参现在接受像 'INFO' 这样的字符串形式的级别表达方式,也可以使用像 :const:`INFO` 这样的整数常量。"
#: ../../library/logging.rst:445
msgid "Sets the :class:`Formatter` for this handler to *fmt*."
msgstr "将此处理器的 :class:`Formatter` 设置为 *fmt*。"
#: ../../library/logging.rst:450
msgid "Adds the specified filter *filter* to this handler."
msgstr "将指定的过滤器 *filter* 添加到此处理器。"
#: ../../library/logging.rst:455
msgid "Removes the specified filter *filter* from this handler."
msgstr "从此处理器中删除指定的过滤器 *filter* 。"
#: ../../library/logging.rst:460
msgid ""
"Apply this handler's filters to the record and return ``True`` if the record"
" is to be processed. The filters are consulted in turn, until one of them "
"returns a false value. If none of them return a false value, the record will"
" be emitted. If one returns a false value, the handler will not emit the "
"record."
msgstr ""
"将此处理器的过滤器应用于记录,在要处理记录时返回 ``True`` "
"。依次查询过滤器,直到其中一个返回假值为止。如果它们都不返回假值,则将发出记录。如果返回一个假值,则处理器将不会发出记录。"
#: ../../library/logging.rst:469
msgid ""
"Ensure all logging output has been flushed. This version does nothing and is"
" intended to be implemented by subclasses."
msgstr "确保所有日志记录从缓存输出。此版本不执行任何操作,并且应由子类实现。"
#: ../../library/logging.rst:475
msgid ""
"Tidy up any resources used by the handler. This version does no output but "
"removes the handler from an internal list of handlers which is closed when "
":func:`shutdown` is called. Subclasses should ensure that this gets called "
"from overridden :meth:`close` methods."
msgstr ""
"回收处理器使用的所有资源。此版本不输出,但从内部处理器列表中删除处理器,内部处理器在 :func:`shutdown` 被调用时关闭 "
"。子类应确保从重写的 :meth:`close` 方法中调用此方法。"
#: ../../library/logging.rst:483
msgid ""
"Conditionally emits the specified logging record, depending on filters which"
" may have been added to the handler. Wraps the actual emission of the record"
" with acquisition/release of the I/O thread lock."
msgstr "经已添加到处理器的过滤器过滤后,有条件地发出指定的日志记录。用获取/释放 I/O 线程锁包装了记录的实际发出行为。"
#: ../../library/logging.rst:490
msgid ""
"This method should be called from handlers when an exception is encountered "
"during an :meth:`emit` call. If the module-level attribute "
"``raiseExceptions`` is ``False``, exceptions get silently ignored. This is "
"what is mostly wanted for a logging system - most users will not care about "
"errors in the logging system, they are more interested in application "
"errors. You could, however, replace this with a custom handler if you wish. "
"The specified record is the one which was being processed when the exception"
" occurred. (The default value of ``raiseExceptions`` is ``True``, as that is"
" more useful during development)."
msgstr ""
"调用 :meth:`emit` 期间遇到异常时,应从处理器中调用此方法。如果模块级属性 ``raiseExceptions`` 是 "
"``False``,则异常将被静默忽略。这是大多数情况下日志系统需要的 —— "
"大多数用户不会关心日志系统中的错误,他们对应用程序错误更感兴趣。但是,你可以根据需要将其替换为自定义处理器。指定的记录是发生异常时正在处理的记录。(``raiseExceptions``"
" 的默认值是 ``True``,因为这在开发过程中是比较有用的)。"
#: ../../library/logging.rst:503
msgid ""
"Do formatting for a record - if a formatter is set, use it. Otherwise, use "
"the default formatter for the module."
msgstr "如果设置了格式器则用其对记录进行格式化。否则,使用模块的默认格式器。"
#: ../../library/logging.rst:509
msgid ""
"Do whatever it takes to actually log the specified logging record. This "
"version is intended to be implemented by subclasses and so raises a "
":exc:`NotImplementedError`."
msgstr "执行实际记录给定日志记录所需的操作。这个版本应由子类实现,因此这里直接引发 :exc:`NotImplementedError` 异常。"
#: ../../library/logging.rst:513
msgid ""
"For a list of handlers included as standard, see :mod:`logging.handlers`."
msgstr "有关作为标准随附的处理器列表,请参见 :mod:`logging.handlers`。"
#: ../../library/logging.rst:518
msgid "Formatter Objects"
msgstr "格式器对象"
#: ../../library/logging.rst:522
msgid ""
":class:`Formatter` objects have the following attributes and methods. They "
"are responsible for converting a :class:`LogRecord` to (usually) a string "
"which can be interpreted by either a human or an external system. The base "
":class:`Formatter` allows a formatting string to be specified. If none is "
"supplied, the default value of ``'%(message)s'`` is used, which just "
"includes the message in the logging call. To have additional items of "
"information in the formatted output (such as a timestamp), keep reading."
msgstr ""
":class:`Formatter` 对象拥有以下的属性和方法。一般情况下,它们负责将 :class:`LogRecord` "
"转换为可由人或外部系统解释的字符串。基础的 :class:`Formatter` 允许指定格式字符串。如果未提供任何值,则使用默认值 "
"``'%(message)s'`` ,它仅将消息包括在日志记录调用中。要在格式化输出中包含其他信息(如时间戳),请阅读下文。 "
#: ../../library/logging.rst:530
msgid ""
"A Formatter can be initialized with a format string which makes use of "
"knowledge of the :class:`LogRecord` attributes - such as the default value "
"mentioned above making use of the fact that the user's message and arguments"
" are pre-formatted into a :class:`LogRecord`'s *message* attribute. This "
"format string contains standard Python %-style mapping keys. See section "
":ref:`old-string-formatting` for more information on string formatting."
msgstr ""
"格式器可以使用格式化字符串来初始化,该字符串利用 :class:`LogRecord` 的属性 —— 例如上述默认值,用户的消息和参数预先格式化为 "
":class:`LogRecord` 的 *message* 属性后被使用。此格式字符串包含标准的 Python %-s "
"样式映射键。有关字符串格式的更多信息,请参见 :ref:`old-string-formatting`。"
#: ../../library/logging.rst:537
msgid ""
"The useful mapping keys in a :class:`LogRecord` are given in the section on "
":ref:`logrecord-attributes`."
msgstr ":ref:`logrecord-attributes` 一节中给出了 :class:`LogRecord` 中有用的映射键。"
#: ../../library/logging.rst:543
msgid ""
"Returns a new instance of the :class:`Formatter` class. The instance is "
"initialized with a format string for the message as a whole, as well as a "
"format string for the date/time portion of a message. If no *fmt* is "
"specified, ``'%(message)s'`` is used. If no *datefmt* is specified, a "
"format is used which is described in the :meth:`formatTime` documentation."
msgstr ""
"返回 :class:`Formatter` 类的新实例。实例将使用整个消息的格式字符串以及消息的日期/时间部分的格式字符串进行初始化。如果未指定 "
"*fmt* ,则使用 ``'%(message)s'``。如果未指定 *datefmt*,则使用 :meth:`formatTime` "
"文档中描述的格式。"
#: ../../library/logging.rst:549
msgid ""
"The *style* parameter can be one of '%', '{' or '$' and determines how the "
"format string will be merged with its data: using one of %-formatting, "
":meth:`str.format` or :class:`string.Template`. This only applies to the "
"format string *fmt* (e.g. ``'%(message)s'`` or ``{message}``), not to the "
"actual log messages passed to ``Logger.debug`` etc; see :ref:`formatting-"
"styles` for more information on using {- and $-formatting for log messages."
msgstr ""
"*style* 形参可以是 '%', '{' 或 '$' 之一,它决定格式字符串将如何与数据进行合并:使用 %-formatting, "
":meth:`str.format` 或是 :class:`string.Template`。 这仅适用于格式字符串 *fmt* (例如 "
"``'%(message)s'`` 或 ``{message}``),不适用于传递给 ``Logger.debug`` 的实际日志消息等;请参阅 "
":ref:`formatting-styles` 了解有关在日志消息中使用 {- 和 $-formatting 的更多详情。"
#: ../../library/logging.rst:557
msgid "The *style* parameter was added."
msgstr "加入了 *style* 形参。"
#: ../../library/logging.rst:560
msgid ""
"The *validate* parameter was added. Incorrect or mismatched style and fmt "
"will raise a ``ValueError``. For example: ``logging.Formatter('%(asctime)s -"
" %(message)s', style='{')``."
msgstr ""
"加入*validate* 参数。不正确或不匹配的样式和格式将引发 ``ValueError`` 错误。例如: "
"``logging.Formatter('%(asctime)s - %(message)s', style='{')``。"
#: ../../library/logging.rst:567
msgid ""
"The record's attribute dictionary is used as the operand to a string "
"formatting operation. Returns the resulting string. Before formatting the "
"dictionary, a couple of preparatory steps are carried out. The *message* "
"attribute of the record is computed using *msg* % *args*. If the formatting "
"string contains ``'(asctime)'``, :meth:`formatTime` is called to format the "
"event time. If there is exception information, it is formatted using "
":meth:`formatException` and appended to the message. Note that the formatted"
" exception information is cached in attribute *exc_text*. This is useful "
"because the exception information can be pickled and sent across the wire, "
"but you should be careful if you have more than one :class:`Formatter` "
"subclass which customizes the formatting of exception information. In this "
"case, you will have to clear the cached value after a formatter has done its"
" formatting, so that the next formatter to handle the event doesn't use the "
"cached value but recalculates it afresh."
msgstr ""
"记录的属性字典用作字符串格式化操作的参数。返回结果字符串。在格式化字典之前,需要执行几个准备步骤。 使用 *msg* % *args* 计算记录的 "
"*message* 属性。如果格式化字符串包含 ``'(asctime)'``,则调用 :meth:`formatTime` "
"来格式化事件时间。如果有异常信息,则使用 :meth:`formatException` 将其格式化并附加到消息中。请注意,格式化的异常信息缓存在属性 "
"*exc_text* 中。这很有用,因为可以对异常信息进行序列化并通过网络发送,但是如果您有不止一个定制了异常信息格式的 "
":class:`Formatter` "
"子类,则应格外小心。在这种情况下,您必须在格式器完成格式化后清除缓存的值,以便下一个处理事件的格式器不使用缓存的值,而是重新计算它。"
#: ../../library/logging.rst:583
msgid ""
"If stack information is available, it's appended after the exception "
"information, using :meth:`formatStack` to transform it if necessary."
msgstr "如果栈信息可用,它将被添加在异常信息之后,如有必要请使用 :meth:`formatStack` 来转换它。"
#: ../../library/logging.rst:589
msgid ""
"This method should be called from :meth:`format` by a formatter which wants "
"to make use of a formatted time. This method can be overridden in formatters"
" to provide for any specific requirement, but the basic behavior is as "
"follows: if *datefmt* (a string) is specified, it is used with "
":func:`time.strftime` to format the creation time of the record. Otherwise, "
"the format '%Y-%m-%d %H:%M:%S,uuu' is used, where the uuu part is a "
"millisecond value and the other letters are as per the :func:`time.strftime`"
" documentation. An example time in this format is ``2003-01-23 "
"00:29:50,411``. The resulting string is returned."
msgstr ""
"此方法应由想要使用格式化时间的格式器中的 :meth:`format` 调用。可以在格式器中重写此方法以提供任何特定要求,但是基本行为如下:如果指定了 "
"*datefmt* (字符串),则将其用于 :func:`time.strftime` 来格式化记录的创建时间。否则,使用格式 '%Y-%m-%d "
"%H:%M:%S,uuu',其中 uuu 部分是毫秒值,其他字母根据 :func:`time.strftime` 文档。这种时间格式的示例为 "
"``2003-01-23 00:29:50,411``。返回结果字符串。"
#: ../../library/logging.rst:599
msgid ""
"This function uses a user-configurable function to convert the creation time"
" to a tuple. By default, :func:`time.localtime` is used; to change this for "
"a particular formatter instance, set the ``converter`` attribute to a "
"function with the same signature as :func:`time.localtime` or "
":func:`time.gmtime`. To change it for all formatters, for example if you "
"want all logging times to be shown in GMT, set the ``converter`` attribute "
"in the ``Formatter`` class."
msgstr ""
"此函数使用一个用户可配置函数将创建时间转换为元组。 默认情况下,使用 "
":func:`time.localtime`;要为特定格式化程序实例更改此项,请将实例的 ``converter`` 属性设为具有与 "
":func:`time.localtime` 或 :func:`time.gmtime` 相同签名的函数。 "
"要为所有格式化程序更改此项,例如当你希望所有日志时间都显示为 GMT,请在 ``Formatter`` 类中设置 ``converter`` 属性。"
#: ../../library/logging.rst:607
msgid ""
"Previously, the default format was hard-coded as in this example: "
"``2010-09-06 22:38:15,292`` where the part before the comma is handled by a "
"strptime format string (``'%Y-%m-%d %H:%M:%S'``), and the part after the "
"comma is a millisecond value. Because strptime does not have a format "
"placeholder for milliseconds, the millisecond value is appended using "
"another format string, ``'%s,%03d'`` --- and both of these format strings "
"have been hardcoded into this method. With the change, these strings are "
"defined as class-level attributes which can be overridden at the instance "
"level when desired. The names of the attributes are ``default_time_format`` "
"(for the strptime format string) and ``default_msec_format`` (for appending "
"the millisecond value)."
msgstr ""
"在之前版本中,默认格式是被硬编码的,例如这个例子: ``2010-09-06 22:38:15,292`` 其中逗号之前的部分由 strptime "
"格式字符串 (``'%Y-%m-%d %H:%M:%S'``) 处理,而逗号之后的部分为毫秒值。 因为 strptime "
"没有表示毫秒的占位符,毫秒值使用了另外的格式字符串来添加 ``'%s,%03d'`` --- 这两个格式字符串代码都是硬编码在该方法中的。 "
"经过修改,这些字符串被定义为类层级的属性,当需要时可以在实例层级上被重写。 属性的名称为 ``default_time_format`` (用于 "
"strptime 格式字符串) 和 ``default_msec_format`` (用于添加毫秒值)。"
#: ../../library/logging.rst:620
msgid "The ``default_msec_format`` can be ``None``."
msgstr "``default_msec_format`` 可以为 ``None``。"
#: ../../library/logging.rst:625
msgid ""
"Formats the specified exception information (a standard exception tuple as "
"returned by :func:`sys.exc_info`) as a string. This default implementation "
"just uses :func:`traceback.print_exception`. The resulting string is "
"returned."
msgstr ""
"将指定的异常信息(由 :func:`sys.exc_info` 返回的标准异常元组)格式化为字符串。默认实现只是使用了 "
":func:`traceback.print_exception`。 结果字符串将被返回。"
#: ../../library/logging.rst:632
msgid ""
"Formats the specified stack information (a string as returned by "
":func:`traceback.print_stack`, but with the last newline removed) as a "
"string. This default implementation just returns the input value."
msgstr ""
"将指定的堆栈信息(由 :func:`traceback.print_stack` 返回的字符串,但移除末尾的换行符)格式化为字符串。 "
"默认实现只是返回输入值。"
#: ../../library/logging.rst:639
msgid "Filter Objects"
msgstr "过滤器对象"
#: ../../library/logging.rst:641
msgid ""
"``Filters`` can be used by ``Handlers`` and ``Loggers`` for more "
"sophisticated filtering than is provided by levels. The base filter class "
"only allows events which are below a certain point in the logger hierarchy. "
"For example, a filter initialized with 'A.B' will allow events logged by "
"loggers 'A.B', 'A.B.C', 'A.B.C.D', 'A.B.D' etc. but not 'A.BB', 'B.A.B' etc."
" If initialized with the empty string, all events are passed."
msgstr ""
"``Filters`` 可被 ``Handlers`` 和 ``Loggers`` 用来实现比按层级提供更复杂的过滤操作。 "
"基本过滤器类只允许低于日志记录器层级结构中低于特定层级的事件。 例如,一个用 'A.B' 初始化的过滤器将允许 'A.B', 'A.B.C', "
"'A.B.C.D', 'A.B.D' 等日志记录器所记录的事件。 但 'A.BB', 'B.A.B' 等则不允许。 "
"如果用空字符串初始化,则所有事件都会通过。"
#: ../../library/logging.rst:651
msgid ""
"Returns an instance of the :class:`Filter` class. If *name* is specified, it"
" names a logger which, together with its children, will have its events "
"allowed through the filter. If *name* is the empty string, allows every "
"event."
msgstr ""
"返回一个 :class:`Filter` 类的实例。 如果指定了 "
"*name*,则它将被用来为日志记录器命名,该类及其子类将通过该过滤器允许指定事件通过。 如果 *name* 为空字符串,则允许所有事件通过。"
#: ../../library/logging.rst:658
msgid ""
"Is the specified record to be logged? Returns zero for no, nonzero for yes. "
"If deemed appropriate, the record may be modified in-place by this method."
msgstr "是否要记录指定的记录?返回零表示否,非零表示是。如果认为合适,则可以通过此方法就地修改记录。"
#: ../../library/logging.rst:662
msgid ""
"Note that filters attached to handlers are consulted before an event is "
"emitted by the handler, whereas filters attached to loggers are consulted "
"whenever an event is logged (using :meth:`debug`, :meth:`info`, etc.), "
"before sending an event to handlers. This means that events which have been "
"generated by descendant loggers will not be filtered by a logger's filter "
"setting, unless the filter has also been applied to those descendant "
"loggers."
msgstr ""
"请注意关联到处理器的过滤器会在事件由处理器发出之前被查询,而关联到日志记录器的过滤器则会在有事件被记录的的任何时候(使用 :meth:`debug`, "
":meth:`info` 等等)在将事件发送给处理器之前被查询。 "
"这意味着由后代日志记录器生成的事件将不会被父代日志记录器的过滤器设置所过滤,除非该过滤器也已被应用于后代日志记录器。"
#: ../../library/logging.rst:669
msgid ""
"You don't actually need to subclass ``Filter``: you can pass any instance "
"which has a ``filter`` method with the same semantics."
msgstr "你实际上不需要子类化 ``Filter`` :你可以传入任何一个包含有相同语义的 ``filter`` 方法的实例。"
#: ../../library/logging.rst:672
msgid ""