# SOME DESCRIPTIVE TITLE. # Copyright (C) 2001-2021, Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR , YEAR. # # Translators: # tomo, 2019 # Mukai Shohei , 2019 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.7\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-01 16:02+0000\n" "PO-Revision-Date: 2019-09-01 03:36+0000\n" "Last-Translator: Mukai Shohei , 2019\n" "Language-Team: Japanese (https://www.transifex.com/python-doc/teams/5390/" "ja/)\n" "Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/logging.rst:3 msgid "Logging HOWTO" msgstr "Logging HOWTO" #: ../../howto/logging.rst:0 msgid "Author" msgstr "著者" #: ../../howto/logging.rst:5 msgid "Vinay Sajip " msgstr "Vinay Sajip " #: ../../howto/logging.rst:12 msgid "Basic Logging Tutorial" msgstr "基本 logging チュートリアル" #: ../../howto/logging.rst:14 msgid "" "Logging is a means of tracking events that happen when some software runs. " "The software's developer adds logging calls to their code to indicate that " "certain events have occurred. An event is described by a descriptive message " "which can optionally contain variable data (i.e. data that is potentially " "different for each occurrence of the event). Events also have an importance " "which the developer ascribes to the event; the importance can also be called " "the *level* or *severity*." msgstr "" "logging は、あるソフトウェアが実行されているときに起こったイベントを追跡する" "ための手段です。ソフトウェアの開発者は、特定のイベントが発生したことを示す " "logging の呼び出しをコードに加えます。イベントは、メッセージで記述され、これ" "に変数データ (すなわち、イベントが起こる度に異なるかもしれないデータ) を加え" "ることもできます。イベントには、開発者がそのイベントに定めた重要性も含まれま" "す。重要性は、*レベル (level)* や *重大度 (severity)* とも呼ばれます。" #: ../../howto/logging.rst:23 msgid "When to use logging" msgstr "logging を使うとき" #: ../../howto/logging.rst:25 msgid "" "Logging provides a set of convenience functions for simple logging usage. " "These are :func:`debug`, :func:`info`, :func:`warning`, :func:`error` and :" "func:`critical`. To determine when to use logging, see the table below, " "which states, for each of a set of common tasks, the best tool to use for it." msgstr "" "logging は、単純なロギングの用法に便利な関数群を提供しています。この中に" "は、 :func:`debug`, :func:`info`, :func:`warning`, :func:`error` および :" "func:`critical` があります。logging を使うべき時を決めるには、よくあるタスク" "に使う最適なツールを述べた、以下のテーブルを参照してください。" #: ../../howto/logging.rst:31 msgid "Task you want to perform" msgstr "行いたいタスク" #: ../../howto/logging.rst:31 msgid "The best tool for the task" msgstr "そのタスクに最適なツール" #: ../../howto/logging.rst:33 msgid "" "Display console output for ordinary usage of a command line script or program" msgstr "コマンドラインスクリプトやプログラムで普通に使う、コンソール出力の表示" #: ../../howto/logging.rst:33 msgid ":func:`print`" msgstr ":func:`print`" #: ../../howto/logging.rst:37 msgid "" "Report events that occur during normal operation of a program (e.g. for " "status monitoring or fault investigation)" msgstr "" "プログラムの通常の操作中に発生したイベントの報告 (例えば、状態の監視や障害の" "分析)" #: ../../howto/logging.rst:37 msgid "" ":func:`logging.info` (or :func:`logging.debug` for very detailed output for " "diagnostic purposes)" msgstr "" ":func:`logging.info` (または、診断のための特に詳細な出力には :func:`logging." "debug`)" #: ../../howto/logging.rst:42 msgid "Issue a warning regarding a particular runtime event" msgstr "特定のランタイムイベントに関わる警告の発行" #: ../../howto/logging.rst:42 msgid "" ":func:`warnings.warn` in library code if the issue is avoidable and the " "client application should be modified to eliminate the warning" msgstr "" "その発行が避けられるもので、クライアントアプリケーションを修正してその警告を" "排除するべきなら :func:`warnings.warn`" #: ../../howto/logging.rst:47 msgid "" ":func:`logging.warning` if there is nothing the client application can do " "about the situation, but the event should still be noted" msgstr "" "アプリケーションにできることはないが、それでもイベントを記録するべきなら :" "func:`logging.warning`" #: ../../howto/logging.rst:52 msgid "Report an error regarding a particular runtime event" msgstr "特定のランタイムイベントに関わるエラーの報告" #: ../../howto/logging.rst:52 msgid "Raise an exception" msgstr "例外の送出" #: ../../howto/logging.rst:55 msgid "" "Report suppression of an error without raising an exception (e.g. error " "handler in a long-running server process)" msgstr "" "例外の送出をしないエラーの抑制 (例えば、長期のサーバプロセス中のエラーハンド" "ラ)" #: ../../howto/logging.rst:55 msgid "" ":func:`logging.error`, :func:`logging.exception` or :func:`logging.critical` " "as appropriate for the specific error and application domain" msgstr "" "特定のエラーやアプリケーションドメインに応じて :func:`logging.error`, :func:" "`logging.exception` または :func:`logging.critical`" #: ../../howto/logging.rst:62 msgid "" "The logging functions are named after the level or severity of the events " "they are used to track. The standard levels and their applicability are " "described below (in increasing order of severity):" msgstr "" "ロギング関数は、そのイベントのレベルや重大度から名前を付けられ、それが追跡に" "使われます。標準のレベルとその適用範囲は、以下に (重大度が増す順に) 記述され" "ています:" #: ../../howto/logging.rst:69 ../../howto/logging.rst:846 msgid "Level" msgstr "レベル" #: ../../howto/logging.rst:69 msgid "When it's used" msgstr "いつ使うか" #: ../../howto/logging.rst:71 ../../howto/logging.rst:856 msgid "``DEBUG``" msgstr "``DEBUG``" #: ../../howto/logging.rst:71 msgid "" "Detailed information, typically of interest only when diagnosing problems." msgstr "おもに問題を診断するときにのみ関心があるような、詳細な情報。" #: ../../howto/logging.rst:74 ../../howto/logging.rst:854 msgid "``INFO``" msgstr "``INFO``" #: ../../howto/logging.rst:74 msgid "Confirmation that things are working as expected." msgstr "想定された通りのことが起こったことの確認。" #: ../../howto/logging.rst:77 ../../howto/logging.rst:852 msgid "``WARNING``" msgstr "``WARNING``" #: ../../howto/logging.rst:77 msgid "" "An indication that something unexpected happened, or indicative of some " "problem in the near future (e.g. 'disk space low'). The software is still " "working as expected." msgstr "" "想定外のことが起こった、または問題が近く起こりそうである (例えば、'disk " "space low') ことの表示。" #: ../../howto/logging.rst:82 ../../howto/logging.rst:850 msgid "``ERROR``" msgstr "``ERROR``" #: ../../howto/logging.rst:82 msgid "" "Due to a more serious problem, the software has not been able to perform " "some function." msgstr "より重大な問題により、ソフトウェアがある機能を実行できないこと。" #: ../../howto/logging.rst:85 ../../howto/logging.rst:848 msgid "``CRITICAL``" msgstr "``CRITICAL``" #: ../../howto/logging.rst:85 msgid "" "A serious error, indicating that the program itself may be unable to " "continue running." msgstr "プログラム自体が実行を続けられないことを表す、重大なエラー。" #: ../../howto/logging.rst:89 msgid "" "The default level is ``WARNING``, which means that only events of this level " "and above will be tracked, unless the logging package is configured to do " "otherwise." msgstr "" "デフォルトのレベルは ``WARNING`` で、logging パッケージが他に設定されなけれ" "ば、このレベル以上のイベントのみ追跡されます。" #: ../../howto/logging.rst:93 msgid "" "Events that are tracked can be handled in different ways. The simplest way " "of handling tracked events is to print them to the console. Another common " "way is to write them to a disk file." msgstr "" "追跡されるイベントは、異なる方法で処理されます。追跡されたイベントを処理する" "最も単純な方法は、それをコンソールに表示することです。その他のよくある方法" "は、それをディスクファイルに書き出すことです。" #: ../../howto/logging.rst:101 msgid "A simple example" msgstr "簡単な例" #: ../../howto/logging.rst:103 msgid "A very simple example is::" msgstr "ごく簡単な例は::" #: ../../howto/logging.rst:109 msgid "If you type these lines into a script and run it, you'll see:" msgstr "" "これらの行をスクリプトにタイプして実行すると、次のようにコンソールに出力され" "ます:" #: ../../howto/logging.rst:115 msgid "" "printed out on the console. The ``INFO`` message doesn't appear because the " "default level is ``WARNING``. The printed message includes the indication of " "the level and the description of the event provided in the logging call, i." "e. 'Watch out!'. Don't worry about the 'root' part for now: it will be " "explained later. The actual output can be formatted quite flexibly if you " "need that; formatting options will also be explained later." msgstr "" "デフォルトのレベルは ``WARNING`` なので、``INFO`` メッセージは現れません。表" "示されたメッセージには、レベルの表示と、ロギングの呼び出しで提供された、イベ" "ントの説明すなわち 'Watch out!' が含まれます。'root' の部分は今は気にしないで" "ください。あとで説明します。実際の出力は、必要に応じてかなり柔軟に書式化でき" "ます。書式化操作もあとで説明します。" #: ../../howto/logging.rst:124 msgid "Logging to a file" msgstr "ファイルへの logging" #: ../../howto/logging.rst:126 msgid "" "A very common situation is that of recording logging events in a file, so " "let's look at that next. Be sure to try the following in a newly-started " "Python interpreter, and don't just continue from the session described " "above::" msgstr "" "logging イベントをファイルに記録するのは非常によくあるパターンなので次はこれ" "を見て行きましょう。以下のサンプルを試すときは Python インタプリタを新しく起" "動して、上のセッションの続きにならないようにしてください::" #: ../../howto/logging.rst:136 msgid "" "And now if we open the file and look at what we have, we should find the log " "messages:" msgstr "そして、ファイルの中身を確認すると、ログメッセージが確認できます:" #: ../../howto/logging.rst:145 msgid "" "This example also shows how you can set the logging level which acts as the " "threshold for tracking. In this case, because we set the threshold to " "``DEBUG``, all of the messages were printed." msgstr "" "この例はまた、追跡のしきい値となるロギングレベルを設定する方法も示していま" "す。この例では、しきい値を ``DEBUG`` に設定しているので、全てのメッセージが表" "示されています。" #: ../../howto/logging.rst:149 msgid "" "If you want to set the logging level from a command-line option such as:" msgstr "次のようなコマンドラインオプションでログレベルを設定したいと考え:" #: ../../howto/logging.rst:155 msgid "" "and you have the value of the parameter passed for ``--log`` in some " "variable *loglevel*, you can use::" msgstr "" "``--log`` に渡されたパラメータの値を変数 *loglevel* に保存しているとしたら、" #: ../../howto/logging.rst:160 msgid "" "to get the value which you'll pass to :func:`basicConfig` via the *level* " "argument. You may want to error check any user input value, perhaps as in " "the following example::" msgstr "" "というコードを使い、 :func:`basicConfig` の *level* 引数に渡すべき値が得られ" "ます。\n" "ユーザの入力値をすべてエラーチェックしたくなり、次の例のように実装することも" "あるでしょう::" #: ../../howto/logging.rst:172 msgid "" "The call to :func:`basicConfig` should come *before* any calls to :func:" "`debug`, :func:`info` etc. As it's intended as a one-off simple " "configuration facility, only the first call will actually do anything: " "subsequent calls are effectively no-ops." msgstr "" ":func:`basicConfig` は、 :func:`debug` や :func:`info` などの呼び出しよりも *" "前* に呼び出さなければなりません。これは、一度限りの単純な設定機能を意図して" "いるので、実際に作用するのは最初の呼び出しのみで、続く呼び出しの効果は no-op " "です。" #: ../../howto/logging.rst:177 msgid "" "If you run the above script several times, the messages from successive runs " "are appended to the file *example.log*. If you want each run to start " "afresh, not remembering the messages from earlier runs, you can specify the " "*filemode* argument, by changing the call in the above example to::" msgstr "" "上記のスクリプトを複数回実行すると、2 回目以降の実行によるメッセージは " "*example.log* に加えられます。以前の実行によるメッセージを記憶せず、実行ごと" "に新たに始めたいなら、上記の例での呼び出しを次のように変え、*filemode* 引数を" "指定する方法がとれます::" #: ../../howto/logging.rst:184 msgid "" "The output will be the same as before, but the log file is no longer " "appended to, so the messages from earlier runs are lost." msgstr "" "出力は先ほどと同じになりますが、ログファイルは追記されなくなり、以前の実行に" "よるメッセージは失われます。" #: ../../howto/logging.rst:189 msgid "Logging from multiple modules" msgstr "複数のモジュールからのロギング" #: ../../howto/logging.rst:191 msgid "" "If your program consists of multiple modules, here's an example of how you " "could organize logging in it::" msgstr "" "プログラムが複数のモジュールでできているなら、そのロギングをどのように構成す" "るかの例はこちらです::" #: ../../howto/logging.rst:215 msgid "If you run *myapp.py*, you should see this in *myapp.log*:" msgstr "*myapp.py* を実行すれば、*myapp.log*でログが確認できます:" #: ../../howto/logging.rst:223 msgid "" "which is hopefully what you were expecting to see. You can generalize this " "to multiple modules, using the pattern in *mylib.py*. Note that for this " "simple usage pattern, you won't know, by looking in the log file, *where* in " "your application your messages came from, apart from looking at the event " "description. If you want to track the location of your messages, you'll need " "to refer to the documentation beyond the tutorial level -- see :ref:`logging-" "advanced-tutorial`." msgstr "" "この *mylib.py* でのパターンは、複数のモジュールに一般化できます。なお、この" "簡単な使用パターンでは、ログファイルを見ることで、イベントの説明は見られます" "が、アプリケーションの *どこから* メッセージが来たのかを知ることはできませ" "ん。メッセージの位置を追跡したいなら、このチュートリアルレベルを超えたドキュ" "メントが必要になります -- :ref:`logging-advanced-tutorial` を参照してくださ" "い。" #: ../../howto/logging.rst:233 msgid "Logging variable data" msgstr "変数データのロギング" #: ../../howto/logging.rst:235 msgid "" "To log variable data, use a format string for the event description message " "and append the variable data as arguments. For example::" msgstr "" "変数データのログを取るには、イベント記述メッセージにフォーマット文字列を使" "い、引数に変数データを加えてください。例えば::" #: ../../howto/logging.rst:241 msgid "will display:" msgstr "により、次のように表示されます:" #: ../../howto/logging.rst:247 msgid "" "As you can see, merging of variable data into the event description message " "uses the old, %-style of string formatting. This is for backwards " "compatibility: the logging package pre-dates newer formatting options such " "as :meth:`str.format` and :class:`string.Template`. These newer formatting " "options *are* supported, but exploring them is outside the scope of this " "tutorial: see :ref:`formatting-styles` for more information." msgstr "" "ご覧の通り、イベント記述メッセージに変数データを統合するために、古い、% スタ" "イルの文字列フォーマットを使っています。これは後方互換性のためです。logging " "パッケージは、 :meth:`str.format` や :class:`string.Template` のような新しい" "フォーマットオプションよりも先に生まれました。新しいフォーマットオプションは" "サポートされて *います* が、その探求はこのチュートリアルでは対象としません。" "詳細は :ref:`formatting-styles` を参照してください。" #: ../../howto/logging.rst:256 msgid "Changing the format of displayed messages" msgstr "表示されるメッセージのフォーマットの変更" #: ../../howto/logging.rst:258 msgid "" "To change the format which is used to display messages, you need to specify " "the format you want to use::" msgstr "" "メッセージを表示するのに使われるフォーマットを変更するには、使いたいフォー" "マットを指定する必要があります::" #: ../../howto/logging.rst:267 msgid "which would print:" msgstr "これは次のように表示されます:" #: ../../howto/logging.rst:275 msgid "" "Notice that the 'root' which appeared in earlier examples has disappeared. " "For a full set of things that can appear in format strings, you can refer to " "the documentation for :ref:`logrecord-attributes`, but for simple usage, you " "just need the *levelname* (severity), *message* (event description, " "including variable data) and perhaps to display when the event occurred. " "This is described in the next section." msgstr "" "ご覧の通り、先の例に現れた 'root' が消失しています。フォーマット文字列に含め" "ることができるものの一覧は、 :ref:`logrecord-attributes` のドキュメントから参" "照できますが、単純な用途では、必要なものは *levelname* (重大度)、 *message* " "(変数データを含むイベント記述)、それともしかしたら、イベントがいつ起こったか" "という表示だけです。これは次の節で解説します。" #: ../../howto/logging.rst:284 msgid "Displaying the date/time in messages" msgstr "メッセージ内での日付と時刻の表示" #: ../../howto/logging.rst:286 msgid "" "To display the date and time of an event, you would place '%(asctime)s' in " "your format string::" msgstr "" "イベントの日付と時刻を表示するには、フォーマット文字列に '%(asctime)s' を置い" "てください::" #: ../../howto/logging.rst:293 msgid "which should print something like this:" msgstr "これは以下の様なフォーマットで表示されます:" #: ../../howto/logging.rst:299 msgid "" "The default format for date/time display (shown above) is like ISO8601 or :" "rfc:`3339`. If you need more control over the formatting of the date/time, " "provide a *datefmt* argument to ``basicConfig``, as in this example::" msgstr "" "デフォルトの日付と時間のフォーマットは、ISO8601 (RFC3339) の規格で表示されま" "す (上記の表示結果) 。日付と時間のフォーマットを変更した場合は、以下の例の様" "に、``basicConfig``関数の*datefmt*引数に指定する必要があります:" #: ../../howto/logging.rst:307 msgid "which would display something like this:" msgstr "これは次のように表示されます:" #: ../../howto/logging.rst:313 msgid "" "The format of the *datefmt* argument is the same as supported by :func:`time." "strftime`." msgstr "" "*datefmt* 引数のフォーマットは、 :func:`time.strftime` でサポートされているも" "のと同じです。" #: ../../howto/logging.rst:318 msgid "Next Steps" msgstr "次のステップ" #: ../../howto/logging.rst:320 msgid "" "That concludes the basic tutorial. It should be enough to get you up and " "running with logging. There's a lot more that the logging package offers, " "but to get the best out of it, you'll need to invest a little more of your " "time in reading the following sections. If you're ready for that, grab some " "of your favourite beverage and carry on." msgstr "" "基本チュートリアルはこれで終わりです。あなたがロギングを使っていくためには、" "これで十分でしょう。logging パッケージが提供するものはもっとありますが、それ" "を使いこなすためには、もうちょっと時間をかけて、以下のセクションを読む必要が" "あります。その用意ができたら、好きな飲み物を持って、次に進みましょう。" #: ../../howto/logging.rst:326 msgid "" "If your logging needs are simple, then use the above examples to incorporate " "logging into your own scripts, and if you run into problems or don't " "understand something, please post a question on the comp.lang.python Usenet " "group (available at https://groups.google.com/forum/#!forum/comp.lang." "python) and you should receive help before too long." msgstr "" "ロギングを簡潔に行いたいなら、上記の例を使って、ロギングをあなたのスクリプト" "に組み込んでください。問題があったり理解出来ないことがあったら、comp.lang." "python Usenet group (https://groups.google.com/forum/#!forum/comp.lang." "python から利用できます) に質問を投稿してくだされば、そう遠くないうちに助けが" "得られるでしょう。" #: ../../howto/logging.rst:332 msgid "" "Still here? You can carry on reading the next few sections, which provide a " "slightly more advanced/in-depth tutorial than the basic one above. After " "that, you can take a look at the :ref:`logging-cookbook`." msgstr "" "まだいますか?もう少し上級の、踏み込んだチュートリアルを綴った、幾つかの節を" "読み続けることができます。その後で、 :ref:`logging-cookbook` もご覧ください。" #: ../../howto/logging.rst:340 msgid "Advanced Logging Tutorial" msgstr "上級ロギングチュートリアル" #: ../../howto/logging.rst:342 msgid "" "The logging library takes a modular approach and offers several categories " "of components: loggers, handlers, filters, and formatters." msgstr "" "logging ライブラリはモジュール方式のアプローチを取り、いくつかのカテゴリの部" "品を提供します。ロガー、ハンドラ、フィルタ、フォーマッタです。" #: ../../howto/logging.rst:345 msgid "Loggers expose the interface that application code directly uses." msgstr "ロガーは、アプリケーションコードが直接使うインタフェースを公開します。" #: ../../howto/logging.rst:346 msgid "" "Handlers send the log records (created by loggers) to the appropriate " "destination." msgstr "" "ハンドラは、(ロガーによって生成された) ログ記録を適切な送信先に送ります。" #: ../../howto/logging.rst:348 msgid "" "Filters provide a finer grained facility for determining which log records " "to output." msgstr "" "フィルタは、どのログ記録を出力するかを決定する、きめ細かい機能を提供します。" #: ../../howto/logging.rst:350 msgid "Formatters specify the layout of log records in the final output." msgstr "フォーマッタは、ログ記録が最終的に出力されるレイアウトを指定します。" #: ../../howto/logging.rst:352 msgid "" "Log event information is passed between loggers, handlers, filters and " "formatters in a :class:`LogRecord` instance." msgstr "" "ログイベント情報は :class:`LogRecord` インスタンスの形で、 logger, handler, " "filter, formatter の間でやりとりされます。" #: ../../howto/logging.rst:355 msgid "" "Logging is performed by calling methods on instances of the :class:`Logger` " "class (hereafter called :dfn:`loggers`). Each instance has a name, and they " "are conceptually arranged in a namespace hierarchy using dots (periods) as " "separators. For example, a logger named 'scan' is the parent of loggers " "'scan.text', 'scan.html' and 'scan.pdf'. Logger names can be anything you " "want, and indicate the area of an application in which a logged message " "originates." msgstr "" "ロギングは、 :class:`Logger` クラスのインスタンス (以下 :dfn:`ロガー`) にメ" "ソッドを呼び出すことで実行されます。各インスタンスには名前があり、名前空間階" "層構造に、ドット (ピリオド) をセパレータとして、概念的に並べられています。例" "えば、 'scan' という名前のロガーは、ロガー 'scan.text', 'scan.html' および " "'scan.pdf'の親です。ロガー名は、何でも望むものにでき、ロギングされたメッセー" "ジが発生した場所を指し示します。" #: ../../howto/logging.rst:362 msgid "" "A good convention to use when naming loggers is to use a module-level " "logger, in each module which uses logging, named as follows::" msgstr "" "ロガーに名前をつけるときの良い習慣は、ロギングを使う各モジュールに、以下のよ" "うに名付けられた、モジュールレベルロガーを使うことです::" #: ../../howto/logging.rst:367 msgid "" "This means that logger names track the package/module hierarchy, and it's " "intuitively obvious where events are logged just from the logger name." msgstr "" "これにより、ロガー名はパッケージ/モジュール階層をなぞり、ロガー名だけで、どこ" "でイベントのログが取られたか、直感的に明らかになります。" #: ../../howto/logging.rst:370 msgid "" "The root of the hierarchy of loggers is called the root logger. That's the " "logger used by the functions :func:`debug`, :func:`info`, :func:`warning`, :" "func:`error` and :func:`critical`, which just call the same-named method of " "the root logger. The functions and the methods have the same signatures. The " "root logger's name is printed as 'root' in the logged output." msgstr "" "ロガーの階層構造の根源は、ルートロガーと呼ばれます。それが、関数 :func:" "`debug`, :func:`info`, :func:`warning`, :func:`error` および :func:" "`critical` によって使われるロガーとなります。これらの関数は単に、ルートロガー" "の同名のメソッドを呼び出します。これらの関数とメソッドは、同じ署名をもってい" "ます。ルートロガーの名前は、ログ出力では 'root' と表示されます。" #: ../../howto/logging.rst:376 msgid "" "It is, of course, possible to log messages to different destinations. " "Support is included in the package for writing log messages to files, HTTP " "GET/POST locations, email via SMTP, generic sockets, queues, or OS-specific " "logging mechanisms such as syslog or the Windows NT event log. Destinations " "are served by :dfn:`handler` classes. You can create your own log " "destination class if you have special requirements not met by any of the " "built-in handler classes." msgstr "" "もちろん、メッセージを異なる送信先に記録することも出来ます。このパッケージで" "は、ファイルへ、 HTTP GET/POST 先へ、 SMTP 経由で電子メールへ、汎用のソケット" "へ、キューへ、または Windows NT イベントログのような OS 毎のログ記録機構へ" "の、ログメッセージの書きこみがサポートされています。送信先は、 :dfn:" "`handler` クラスによって取り扱われます。組み込みのハンドラクラスでは満たせな" "いような、特殊な要件があるなら、独自のログ送信先を生成できます。" #: ../../howto/logging.rst:383 msgid "" "By default, no destination is set for any logging messages. You can specify " "a destination (such as console or file) by using :func:`basicConfig` as in " "the tutorial examples. If you call the functions :func:`debug`, :func:" "`info`, :func:`warning`, :func:`error` and :func:`critical`, they will check " "to see if no destination is set; and if one is not set, they will set a " "destination of the console (``sys.stderr``) and a default format for the " "displayed message before delegating to the root logger to do the actual " "message output." msgstr "" "デフォルトでは、どのロギングメッセージに対しても、送信先は設定されていませ" "ん。チュートリアルの例のように、 :func:`basicConfig` を使って、送信先 (コン" "ソールやファイルなど) を指定できます。関数 :func:`debug`, :func:`info`, :" "func:`warning`, :func:`error` および :func:`critical` を呼び出すと、それらは" "送信先が設定されていないかを調べます。そして設定されていなければ、ルートロ" "ガーに委譲して実際にメッセージを出力する前に、コンソール (``sys.stderr``) を" "送信先に、デフォルトのフォーマットを表示されるメッセージに設定します。" #: ../../howto/logging.rst:391 msgid "The default format set by :func:`basicConfig` for messages is:" msgstr "" ":func:`basicConfig` によるデフォルトのフォーマットメッセージは次のようになり" "ます:" #: ../../howto/logging.rst:397 msgid "" "You can change this by passing a format string to :func:`basicConfig` with " "the *format* keyword argument. For all options regarding how a format string " "is constructed, see :ref:`formatter-objects`." msgstr "" ":func:`basicConfig` の *format* キーワード引数にフォーマット文字列を渡すこと" "で、これを変更できます。フォーマット文字列を構成するためのすべてのオプション" "は、 :ref:`formatter-objects` を参照してください。" #: ../../howto/logging.rst:402 msgid "Logging Flow" msgstr "Logging Flow" #: ../../howto/logging.rst:404 msgid "" "The flow of log event information in loggers and handlers is illustrated in " "the following diagram." msgstr "" "次の図はログイベントが logger と handler をどう流れるかを示しています。" #: ../../howto/logging.rst:410 msgid "Loggers" msgstr "ロガー" #: ../../howto/logging.rst:412 msgid "" ":class:`Logger` objects have a threefold job. First, they expose several " "methods to application code so that applications can log messages at " "runtime. Second, logger objects determine which log messages to act upon " "based upon severity (the default filtering facility) or filter objects. " "Third, logger objects pass along relevant log messages to all interested log " "handlers." msgstr "" ":class:`Logger` オブジェクトの仕事は大きく三つに分かれます。一つ目は、アプリ" "ケーションが実行中にメッセージを記録できるように、いくつかのメソッドをアプリ" "ケーションから呼べるようにしています。二つ目に、ロガーオブジェクトはどのメッ" "セージに対して作用するかを、深刻度 (デフォルトのフィルタ機構) またはフィルタ" "オブジェクトに基づいて決定します。三つ目に、ロガーオブジェクトは関心を持って" "いるすべてのログハンドラに関連するログメッセージを回送します。" #: ../../howto/logging.rst:418 msgid "" "The most widely used methods on logger objects fall into two categories: " "configuration and message sending." msgstr "" "とりわけ広く使われるロガーオブジェクトのメソッドは、二つのカテゴリーに分類で" "きます: 設定とメッセージ送信です。" #: ../../howto/logging.rst:421 msgid "These are the most common configuration methods:" msgstr "これらが設定メソッドの中でよく使われます:" #: ../../howto/logging.rst:423 msgid "" ":meth:`Logger.setLevel` specifies the lowest-severity log message a logger " "will handle, where debug is the lowest built-in severity level and critical " "is the highest built-in severity. For example, if the severity level is " "INFO, the logger will handle only INFO, WARNING, ERROR, and CRITICAL " "messages and will ignore DEBUG messages." msgstr "" ":meth:`Logger.setLevel` はロガーが扱うログメッセージの最も低い深刻度を指定し" "ます。組み込みの深刻度の中では DEBUG が一番低く、 CRITICAL が一番高くなりま" "す。たとえば、深刻度が INFO と設定されたロガーは INFO, WARNING, ERROR, " "CRITICAL のメッセージしか扱わず、 DEBUG メッセージは無視します。" #: ../../howto/logging.rst:429 msgid "" ":meth:`Logger.addHandler` and :meth:`Logger.removeHandler` add and remove " "handler objects from the logger object. Handlers are covered in more detail " "in :ref:`handler-basic`." msgstr "" ":meth:`Logger.addHandler` と :meth:`Logger.removeHandler` は、ハンドラオブ" "ジェクトをロガーオブジェクトから追加または削除します。ハンドラについては、 :" "ref:`handler-basic` で詳しく述べます。" #: ../../howto/logging.rst:433 msgid "" ":meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove " "filter objects from the logger object. Filters are covered in more detail " "in :ref:`filter`." msgstr "" ":meth:`Logger.addFilter` と :meth:`Logger.removeFilter` はロガーオブジェクト" "にフィルタオブジェクトを追加または削除します。フィルタについては、 :ref:" "`filter` で詳しく述べます。" #: ../../howto/logging.rst:437 msgid "" "You don't need to always call these methods on every logger you create. See " "the last two paragraphs in this section." msgstr "" "これらのメソッドを、生成したすべてのロガーに毎回呼び出さなければならないわけ" "ではありません。最後の 2 段落を参照してください。" #: ../../howto/logging.rst:440 msgid "" "With the logger object configured, the following methods create log messages:" msgstr "" "ロガーオブジェクトが設定されれば、以下のメソッドがログメッセージを生成します:" #: ../../howto/logging.rst:442 msgid "" ":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:" "`Logger.error`, and :meth:`Logger.critical` all create log records with a " "message and a level that corresponds to their respective method names. The " "message is actually a format string, which may contain the standard string " "substitution syntax of ``%s``, ``%d``, ``%f``, and so on. The rest of their " "arguments is a list of objects that correspond with the substitution fields " "in the message. With regard to ``**kwargs``, the logging methods care only " "about a keyword of ``exc_info`` and use it to determine whether to log " "exception information." msgstr "" ":meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, :meth:" "`Logger.error`, :meth:`Logger.critical` はすべて、メッセージとメソッド名に対" "応したレベルでログ記録を作り出します。メッセージは実際にはフォーマット文字列" "であり、通常の文字列代入に使う ``%s``, ``%d``, ``%f`` などを含むことができま" "す。残りの引数はメッセージの代入される位置に対応するオブジェクトのリストで" "す。 ``**kwargs`` については、ログ記録メソッドが気にするキーワードは " "``exc_info`` だけで、例外の情報をログに記録するかを決定するのに使います。" #: ../../howto/logging.rst:452 msgid "" ":meth:`Logger.exception` creates a log message similar to :meth:`Logger." "error`. The difference is that :meth:`Logger.exception` dumps a stack trace " "along with it. Call this method only from an exception handler." msgstr "" ":meth:`Logger.exception` は :meth:`Logger.error` と似たログメッセージを作成し" "ます。違いは :meth:`Logger.exception` がスタックトレースを一緒にダンプするこ" "とです。例外ハンドラでだけ使うようにしてください。" #: ../../howto/logging.rst:456 msgid "" ":meth:`Logger.log` takes a log level as an explicit argument. This is a " "little more verbose for logging messages than using the log level " "convenience methods listed above, but this is how to log at custom log " "levels." msgstr "" ":meth:`Logger.log` はログレベルを明示的な引数として受け取ります。これは上に挙" "げた便宜的なログレベル毎のメソッドを使うより少しコード量が多くなりますが、独" "自のログレベルを使うことができます。" #: ../../howto/logging.rst:460 msgid "" ":func:`getLogger` returns a reference to a logger instance with the " "specified name if it is provided, or ``root`` if not. The names are period-" "separated hierarchical structures. Multiple calls to :func:`getLogger` with " "the same name will return a reference to the same logger object. 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``." msgstr "" ":func:`getLogger` は、指定されればその特定の名前の、そうでなければ ``root`` " "のロガーインスタンスへの参照を返します。ロガーの名前はピリオド区切りの階層構" "造を表します。同じ名前で :func:`getLogger` を複数回呼び出した場合、同一のロ" "ガーオブジェクトへの参照が返されます。階層リストを下ったロガーはリスト上位の" "ロガーの子です。たとえば、名前が ``foo`` であるロガーがあったとして、 ``foo." "bar``, ``foo.bar.baz``, ``foo.bam`` といった名前のロガーはすべて ``foo`` の子" "孫になります。" #: ../../howto/logging.rst:468 msgid "" "Loggers have a concept of *effective level*. If a level is not explicitly " "set on a logger, the level of its parent is used instead as its effective " "level. If the parent has no explicit level set, *its* parent is examined, " "and so on - all ancestors are searched until an explicitly set level is " "found. The root logger always has an explicit level set (``WARNING`` by " "default). When deciding whether to process an event, the effective level of " "the logger is used to determine whether the event is passed to the logger's " "handlers." msgstr "" "ロガーには、*有効レベル (effective level)* の概念があります。ロガーにレベルが" "明示的に設定されていなければ、代わりに親のレベルがその有効レベルとして使われ" "ます。親のレベルが設定されなければ、*その* 親のレベルが確かめられ、以下同様" "に、明示的に設定されたレベルが見つかるまで祖先が探されます。ルートロガーは、" "必ず明示的なレベルが設定されています (デフォルトでは ``WARNING`` です)。イベ" "ントを処理するかを決定するとき、ロガーの有効レベルを使って、イベントがロガー" "のハンドラに渡されるかが決められます。" #: ../../howto/logging.rst:476 msgid "" "Child loggers propagate messages up to the handlers associated with their " "ancestor loggers. Because of this, it is unnecessary to define and configure " "handlers for all the loggers an application uses. It is sufficient to " "configure handlers for a top-level logger and create child loggers as " "needed. (You can, however, turn off propagation by setting the *propagate* " "attribute of a logger to ``False``.)" msgstr "" "子ロガーはメッセージを親ロガーのハンドラに伝えます。このため、アプリケーショ" "ンが使っているすべてのロガーのためのハンドラを定義して設定する必要はありませ" "ん。トップレベルのロガーのためのハンドラだけ設定しておいて必要に応じて子ロ" "ガーを作成すれば十分です。(しかし、ロガーの *propagate* 属性を ``False`` に設" "定することで、伝播を抑制できます。)" #: ../../howto/logging.rst:487 msgid "Handlers" msgstr "ハンドラ" #: ../../howto/logging.rst:489 msgid "" ":class:`~logging.Handler` objects are responsible for dispatching the " "appropriate log messages (based on the log messages' severity) to the " "handler's specified destination. :class:`Logger` objects can add zero or " "more handler objects to themselves with an :meth:`~Logger.addHandler` " "method. As an example scenario, an application may want to send all log " "messages to a log file, all log messages of error or higher to stdout, and " "all messages of critical to an email address. This scenario requires three " "individual handlers where each handler is responsible for sending messages " "of a specific severity to a specific location." msgstr "" ":class:`~logging.Handler` オブジェクトは適切なログメッセージを (ログメッセー" "ジの深刻度に基づいて) ハンドラの指定された出力先に振り分けることに責任を持ち" "ます。 :class:`Logger` オブジェクトには :meth:`~Logger.addHandler` メソッド" "で 0 個以上のハンドラを追加することができます。例として、あるアプリケーション" "がすべてのログメッセージをログファイルに、 error 以上のすべてのログメッセージ" "を標準出力に、 critical のメッセージはすべてメールアドレスに、それぞれ送りた" "いとします。この場合、 3 つの個別のハンドラがそれぞれの深刻度と宛先に応じて必" "要になります。" #: ../../howto/logging.rst:499 msgid "" "The standard library includes quite a few handler types (see :ref:`useful-" "handlers`); the tutorials use mainly :class:`StreamHandler` and :class:" "`FileHandler` in its examples." msgstr "" "このライブラリには多くのハンドラが用意されています (:ref:`useful-handlers` を" "参照してください) が、このチュートリアルでは :class:`StreamHandler` と :" "class:`FileHandler` だけを例に取り上げます。" #: ../../howto/logging.rst:503 msgid "" "There are very few methods in a handler for application developers to " "concern themselves with. The only handler methods that seem relevant for " "application developers who are using the built-in handler objects (that is, " "not creating custom handlers) are the following configuration methods:" msgstr "" "アプリケーション開発者にとってハンドラを扱う上で気にするべきメソッドは極々限" "られています。組み込みのハンドラオブジェクトを使う (つまり自作ハンドラを作ら" "ない) 開発者に関係あるハンドラのメソッドは、次の設定用のメソッドだけでしょう:" #: ../../howto/logging.rst:508 msgid "" "The :meth:`~Handler.setLevel` method, just as in logger objects, specifies " "the lowest severity that will be dispatched to the appropriate destination. " "Why are there two :func:`setLevel` methods? The level set in the logger " "determines which severity of messages it will pass to its handlers. The " "level set in each handler determines which messages that handler will send " "on." msgstr "" ":meth:`~Handler.setLevel` メソッドは、ロガーオブジェクトの場合と同様に、適切" "な出力先に振り分けられるべき最も低い深刻度を指定します。なぜ 2 つも :func:" "`setLevel` メソッドがあるのでしょうか? ロガーで設定されるレベルは、付随するハ" "ンドラにどんな深刻度のメッセージを渡すか決めます。ハンドラで設定されるレベル" "は、ハンドラがどのメッセージを送るべきか決めます。" #: ../../howto/logging.rst:514 msgid "" ":meth:`~Handler.setFormatter` selects a Formatter object for this handler to " "use." msgstr "" ":meth:`~Handler.setFormatter` でこのハンドラが使用する Formatter オブジェクト" "を選択します。" #: ../../howto/logging.rst:517 msgid "" ":meth:`~Handler.addFilter` and :meth:`~Handler.removeFilter` respectively " "configure and deconfigure filter objects on handlers." msgstr "" ":meth:`~Handler.addFilter` および :meth:`~Handler.removeFilter` はそれぞれハ" "ンドラへのフィルタオブジェクトの設定と解除を行います。" #: ../../howto/logging.rst:520 msgid "" "Application code should not directly instantiate and use instances of :class:" "`Handler`. Instead, the :class:`Handler` class is a base class that defines " "the interface that all handlers should have and establishes some default " "behavior that child classes can use (or override)." msgstr "" "アプリケーションのコード中では :class:`Handler` のインスタンスを直接インスタ" "ンス化して使ってはなりません。代わりに、 :class:`Handler` クラスはすべてのハ" "ンドラが持つべきインターフェイスを定義し、子クラスが使える (もしくはオーバラ" "イドできる) いくつかのデフォルトの振る舞いを規定します。" #: ../../howto/logging.rst:527 msgid "Formatters" msgstr "フォーマッタ" #: ../../howto/logging.rst:529 msgid "" "Formatter objects configure the final order, structure, and contents of the " "log message. Unlike the base :class:`logging.Handler` class, application " "code may instantiate formatter classes, although you could likely subclass " "the formatter if your application needs special behavior. The constructor " "takes three optional arguments -- a message format string, a date format " "string and a style indicator." msgstr "" "フォーマッタオブジェクトは最終的なログメッセージの順序、構造および内容を設定" "します。基底クラスである :class:`logging.Handler` とは違って、アプリケーショ" "ンのコードはフォーマッタクラスをインスタンス化しても構いません。特別な振る舞" "いをさせたいアプリケーションではフォーマッタのサブクラスを使う可能性もありま" "す。コンストラクタは三つのオプション引数を取ります -- メッセージのフォーマッ" "ト文字列、日付のフォーマット文字列、スタイル標識です。" #: ../../howto/logging.rst:538 msgid "" "If there is no message format string, the default is to use the raw " "message. If there is no date format string, the default date format is:" msgstr "" "フォーマット文字列に何も渡さない場合は、デフォルトで行メッセージが利用されま" "す。また、日付フォーマットに何も渡さない場合は、デフォルトで以下のフォーマッ" "トが利用されます:" #: ../../howto/logging.rst:545 msgid "" "with the milliseconds tacked on at the end. The ``style`` is one of `%`, '{' " "or '$'. If one of these is not specified, then '%' will be used." msgstr "" "で、最後にミリ秒が付きます。``style`` は '%', '{', '$' のいずれかです。一つ指" "定されなければ、'%' が使われます。" #: ../../howto/logging.rst:548 msgid "" "If the ``style`` is '%', the message format string uses ``%()s`` styled string substitution; the possible keys are documented in :" "ref:`logrecord-attributes`. If the style is '{', the message format string " "is assumed to be compatible with :meth:`str.format` (using keyword " "arguments), while if the style is '$' then the message format string should " "conform to what is expected by :meth:`string.Template.substitute`." msgstr "" "``style`` が '%' の場合、メッセージフォーマット文字列では ``%()s`` 形式の置換文字列が使われます; キーに指定できる属性名は :ref:" "`logrecord-attributes` に文書化されています。 style が '{' の場合、メッセージ" "フォーマット文字列は (キーワード引数を使う) :meth:`str.format` と互換となりま" "す。 style が '$' の場合、メッセージフォーマット文字列は :meth:`string." "Template.substitute` で期待されているものと一致します。" #: ../../howto/logging.rst:555 msgid "Added the ``style`` parameter." msgstr "``style`` パラメータが追加されました。" #: ../../howto/logging.rst:558 msgid "" "The following message format string will log the time in a human-readable " "format, the severity of the message, and the contents of the message, in " "that order::" msgstr "" "次のメッセージフォーマット文字列は、人が読みやすい形式の時刻、メッセージの深" "刻度、およびメッセージの内容を、順番に出力します::" #: ../../howto/logging.rst:564 msgid "" "Formatters use a user-configurable function to convert the creation time of " "a record to a tuple. By default, :func:`time.localtime` is used; to change " "this for a particular formatter instance, set the ``converter`` attribute of " "the instance 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 (to ``time.gmtime`` for GMT display)." msgstr "" "フォーマッタは、ユーザが設定できる関数を使って、生成時刻をタプルに記録しま" "す。デフォルトでは、 :func:`time.localtime` が使われます。特定のフォーマッタ" "インスタンスに対してこれを変更するには、インスタンスの ``converter`` 属性を :" "func:`time.localtime` や :func:`time.gmtime` と同じ署名をもつ関数に設定してく" "ださい。すべてのフォーマッタインスタンスに対してこれを変更するには、例えば全" "てのロギング時刻を GMT で表示するには、フォーマッタクラスの ``converter`` 属" "性を (GMT 表示の ``time.gmtime`` に) 設定してください。" #: ../../howto/logging.rst:574 msgid "Configuring Logging" msgstr "ロギングの環境設定" #: ../../howto/logging.rst:578 msgid "Programmers can configure logging in three ways:" msgstr "プログラマは、ロギングを 3 種類の方法で設定できます:" #: ../../howto/logging.rst:580 msgid "" "Creating loggers, handlers, and formatters explicitly using Python code that " "calls the configuration methods listed above." msgstr "" "上述の設定メソッドを呼び出す Python コードを明示的に使って、ロガー、ハンド" "ラ、そしてフォーマッタを生成する。" #: ../../howto/logging.rst:582 msgid "" "Creating a logging config file and reading it using the :func:`fileConfig` " "function." msgstr "" "ロギング設定ファイルを作り、それを :func:`fileConfig` 関数を使って読み込む。" #: ../../howto/logging.rst:584 msgid "" "Creating a dictionary of configuration information and passing it to the :" "func:`dictConfig` function." msgstr "設定情報の辞書を作り、それを :func:`dictConfig` 関数に渡す。" #: ../../howto/logging.rst:587 msgid "" "For the reference documentation on the last two options, see :ref:`logging-" "config-api`. The following example configures a very simple logger, a " "console handler, and a simple formatter using Python code::" msgstr "" "最後の2つの選択肢については、 :ref:`logging-config-api` で解説しています。以" "下の例では、Python コードを使って、とても簡単なロガー、コンソールハンドラ、そ" "して簡単なフォーマッタを設定しています::" #: ../../howto/logging.rst:617 msgid "" "Running this module from the command line produces the following output:" msgstr "" "このモジュールを実行すると、コマンドラインによって以下の出力がなされます:" #: ../../howto/logging.rst:628 msgid "" "The following Python module creates a logger, handler, and formatter nearly " "identical to those in the example listed above, with the only difference " "being the names of the objects::" msgstr "" "以下の Python モジュールは、ロガー、ハンドラ、フォーマッタをほとんど上述の例" "と同じように生成していますが、オブジェクト名だけが異なります::" #: ../../howto/logging.rst:647 msgid "Here is the logging.conf file:" msgstr "これは`logging.conf`ファイルに記載する例です:" #: ../../howto/logging.rst:680 msgid "" "The output is nearly identical to that of the non-config-file-based example:" msgstr "出力は、設定ファイルに基づく例とだいたい同じです:" #: ../../howto/logging.rst:691 msgid "" "You can see that the config file approach has a few advantages over the " "Python code approach, mainly separation of configuration and code and the " "ability of noncoders to easily modify the logging properties." msgstr "" "この通り、設定ファイルの方法は、主に設定とコードが分かれ、非コーダがロギング" "プロパティを変えやすくなるという点で、Python コードの方法より少し優れていま" "す。" #: ../../howto/logging.rst:695 msgid "" "The :func:`fileConfig` function takes a default parameter, " "``disable_existing_loggers``, which defaults to ``True`` for reasons of " "backward compatibility. This may or may not be what you want, since it will " "cause any non-root loggers existing before the :func:`fileConfig` call to be " "disabled unless they (or an ancestor) are explicitly named in the " "configuration. Please refer to the reference documentation for more " "information, and specify ``False`` for this parameter if you wish." msgstr "" ":func:`fileConfig` 関数はデフォルト引数 ``disable_existing_loggers`` を取り、" "後方互換性のためにデフォルト値は ``True`` になっています。\n" "これはあなたの望むものかもしれませんし、そうでないかもしれません。というの" "は、設定で明示的に指定したクラス (もしくはその親クラス) を除いて、 :func:" "`fileConfig` が呼び出される前に存在した非ルートロガーを無効化してしまうからで" "す。\n" "より詳細なことはリファレンスを参照し、望むならこの引数に ``False`` を指定して" "ください。" #: ../../howto/logging.rst:703 msgid "" "The dictionary passed to :func:`dictConfig` can also specify a Boolean value " "with key ``disable_existing_loggers``, which if not specified explicitly in " "the dictionary also defaults to being interpreted as ``True``. This leads to " "the logger-disabling behaviour described above, which may not be what you " "want - in which case, provide the key explicitly with a value of ``False``." msgstr "" ":func:`dictConfig` に渡した辞書で、キー ``disable_existing_loggers`` にブール" "値を指定することができ、辞書で指定しなかった場合はデフォルトで ``True`` と解" "釈されます。こうすると上で説明したロガー無効化が動作しますが、これはあなたが" "望んだものでないかもしれません - その場合は、明示的にキーに ``False`` を指定" "してください。" #: ../../howto/logging.rst:713 msgid "" "Note that the class names referenced in config files need to be either " "relative to the logging module, or absolute values which can be resolved " "using normal import mechanisms. Thus, you could use either :class:`~logging." "handlers.WatchedFileHandler` (relative to the logging module) or ``mypackage." "mymodule.MyHandler`` (for a class defined in package ``mypackage`` and " "module ``mymodule``, where ``mypackage`` is available on the Python import " "path)." msgstr "" "なお、設定ファイルで参照されるクラス名は、logging モジュールに対して相対であ" "るか、通常のインポート機構を使って解決される絶対である値でなければなりませ" "ん。従って、(logging モジュールに相対な) :class:`~logging.handlers." "WatchedFileHandler` または (Python インポートパスとして ``mypackage`` が使え" "るとき、パッケージ ``mypackage`` のモジュール ``mymodule`` で定義されたクラス" "に) ``mypackage.mymodule.MyHandler`` のどちらかが使えます。" #: ../../howto/logging.rst:721 msgid "" "In Python 3.2, a new means of configuring logging has been introduced, using " "dictionaries to hold configuration information. This provides a superset of " "the functionality of the config-file-based approach outlined above, and is " "the recommended configuration method for new applications and deployments. " "Because a Python dictionary is used to hold configuration information, and " "since you can populate that dictionary using different means, you have more " "options for configuration. For example, you can use a configuration file in " "JSON format, or, if you have access to YAML processing functionality, a file " "in YAML format, to populate the configuration dictionary. Or, of course, you " "can construct the dictionary in Python code, receive it in pickled form over " "a socket, or use whatever approach makes sense for your application." msgstr "" "Python 3.2 では、ロギングを設定するのに新しく、辞書に設定情報を持たせる手段が" "導入されました。これは、上で概説した設定ファイルに基づく方法による機能の上位" "版を提供し、新しいアプリケーションやデプロイにはこのメソッドが推奨されます。" "Python の辞書を使って設定情報を保持し、辞書は他の用途にも使えるので、設定の選" "択肢が広がります。例えば、JSON フォーマットの設定ファイルや、YAML 処理機能が" "使えれば YAML フォーマットのファイルを使って、設定辞書を構成できます。また、" "もちろん、Python コードで辞書を構成し、ソケットを通して pickle 化された形式を" "受け取るなど、アプリケーションで意味があるいかなるやり方でも使えます。" #: ../../howto/logging.rst:733 msgid "" "Here's an example of the same configuration as above, in YAML format for the " "new dictionary-based approach:" msgstr "" "以下は上記と同じ設定を、辞書形式に基づくYAMLフォーマットとして書いたものです:" #: ../../howto/logging.rst:757 msgid "" "For more information about logging using a dictionary, see :ref:`logging-" "config-api`." msgstr "" "辞書を使ったロギングについて詳細は、 :ref:`logging-config-api` を参照してくだ" "さい。" #: ../../howto/logging.rst:761 msgid "What happens if no configuration is provided" msgstr "環境設定が与えられないとどうなるか" #: ../../howto/logging.rst:763 msgid "" "If no logging configuration is provided, it is possible to have a situation " "where a logging event needs to be output, but no handlers can be found to " "output the event. The behaviour of the logging package in these " "circumstances is dependent on the Python version." msgstr "" "ロギング環境設定を与えられないと、ロギングイベントを出力しなければならないの" "に、イベントを出力するハンドラが見つからないことがあります。この状況での " "logging パッケージの振る舞いは、Python のバージョンに依ります。" #: ../../howto/logging.rst:768 msgid "For versions of Python prior to 3.2, the behaviour is as follows:" msgstr "Python 3.2 より前のバージョンでは、振る舞いは以下の通りです:" #: ../../howto/logging.rst:770 msgid "" "If *logging.raiseExceptions* is ``False`` (production mode), the event is " "silently dropped." msgstr "" "*logging.raiseExceptions* が ``False`` (製品モード) なら、イベントは黙って捨" "てられます。" #: ../../howto/logging.rst:773 msgid "" "If *logging.raiseExceptions* is ``True`` (development mode), a message 'No " "handlers could be found for logger X.Y.Z' is printed once." msgstr "" "*logging.raiseExceptions* が ``True`` (開発モード) なら、メッセージ 'No " "handlers could be found for logger X.Y.Z' が一度表示されます。" #: ../../howto/logging.rst:776 msgid "In Python 3.2 and later, the behaviour is as follows:" msgstr "Python 3.2 以降バージョンでは、振る舞いは以下の通りです:" #: ../../howto/logging.rst:778 msgid "" "The event is output using a 'handler of last resort', stored in ``logging." "lastResort``. This internal handler is not associated with any logger, and " "acts like a :class:`~logging.StreamHandler` which writes the event " "description message to the current value of ``sys.stderr`` (therefore " "respecting any redirections which may be in effect). No formatting is done " "on the message - just the bare event description message is printed. The " "handler's level is set to ``WARNING``, so all events at this and greater " "severities will be output." msgstr "" "イベントは、 ``logging.lastResort`` に格納された「最終手段ハンドラ」を使用し" "て出力されます。この内部的なハンドラはどんなロガーにも関係しておらず、イベン" "ト記述メッセージを現在の ``sys.stderr`` の値に書く :class:`~logging." "StreamHandler` のように動作します (したがって、あらゆるリダイレクトの効果が反" "映されます)。メッセージに対してフォーマットは行われません - 裸のイベント記述" "メッセージだけが印刷されます。ハンドラのレベルは ``WARNING`` にセットされ、こ" "れより重大度が大きなすべてのイベントが出力されます。" #: ../../howto/logging.rst:787 msgid "" "To obtain the pre-3.2 behaviour, ``logging.lastResort`` can be set to " "``None``." msgstr "" "3.2 より前の動作にするために、``logging.lastResort`` を ``None`` に設定するこ" "ともできます。" #: ../../howto/logging.rst:792 msgid "Configuring Logging for a Library" msgstr "ライブラリのためのロギングの設定" #: ../../howto/logging.rst:794 msgid "" "When developing a library which uses logging, you should take care to " "document how the library uses logging - for example, the names of loggers " "used. Some consideration also needs to be given to its logging " "configuration. If the using application does not use logging, and library " "code makes logging calls, then (as described in the previous section) events " "of severity ``WARNING`` and greater will be printed to ``sys.stderr``. This " "is regarded as the best default behaviour." msgstr "" "ロギングを使うライブラリを開発するときは、ライブラリがどのようにロギングを使" "うのか、例えば使われているロガーの名前などを、ドキュメントにしておくべきで" "す。ロギングの設定については、いくつか考えておくべきこともあります。使ってい" "るアプリケーションがロギングを使っていなくて、ライブラリコードがロギングを呼" "び出すと、(前の節で解説したように) 重大度 ``WARNING`` 以上のイベントが、" "``sys.stderr`` に表示されます。これが最高のデフォルトの振る舞いと見なされま" "す。" #: ../../howto/logging.rst:802 msgid "" "If for some reason you *don't* want these messages printed in the absence of " "any logging configuration, you can attach a do-nothing handler to the top-" "level logger for your library. This avoids the message being printed, since " "a handler will always be found for the library's events: it just doesn't " "produce any output. If the library user configures logging for application " "use, presumably that configuration will add some handlers, and if levels are " "suitably configured then logging calls made in library code will send output " "to those handlers, as normal." msgstr "" "何らかの理由で、ロギング設定がなされていないときにメッセージを表示 *させたく" "ない* なら、あなたのライブラリのトップレベルロガーに何もしないハンドラを取り" "付けられます。このハンドラは何も処理しないというだけで、全てのライブラリイベ" "ントに対してハンドラが見つかるので、メッセージが表示されることを防げます。ラ" "イブラリのユーザがアプリケーションでの使用のためにロギングを設定したら、それ" "はおそらくハンドラを追加する設定でしょうが、そしてレベルが適切に設定された" "ら、ライブラリコード内でなされたロギングの呼び出しは、通常通りそのハンドラに" "出力を送るようになります。" #: ../../howto/logging.rst:811 msgid "" "A do-nothing handler is included in the logging package: :class:`~logging." "NullHandler` (since Python 3.1). An instance of this handler could be added " "to the top-level logger of the logging namespace used by the library (*if* " "you want to prevent your library's logged events being output to ``sys." "stderr`` in the absence of logging configuration). If all logging by a " "library *foo* is done using loggers with names matching 'foo.x', 'foo.x.y', " "etc. then the code::" msgstr "" "何もしないハンドラ :class:`~logging.NullHandler` (Python 3.1 以降) は、 " "logging パッケージに含まれます。このハンドラのインスタンスを、 (ロギング設定" "がなされていないときにライブラリのログイベントを ``sys.stderr`` に出力させた" "く *ないなら*) ライブラリの名前空間で使われるトップレベルロガーに取り付けられ" "ます。ライブラリ *foo* によるすべてのロギングが、 'foo.x', 'foo.x.y' その他に" "該当する名前のロガーによってなされるなら::" #: ../../howto/logging.rst:822 msgid "" "should have the desired effect. If an organisation produces a number of " "libraries, then the logger name specified can be 'orgname.foo' rather than " "just 'foo'." msgstr "" "とすれば望んだ効果が得られるでしょう。組織が複数のライブラリを作り出すなら、" "指定されるロガー名は単に 'foo' ではなく、'orgname.foo' になります。" #: ../../howto/logging.rst:826 msgid "" "It is strongly advised that you *do not add any handlers other than* :class:" "`~logging.NullHandler` *to your library's loggers*. This is because the " "configuration of handlers is the prerogative of the application developer " "who uses your library. The application developer knows their target audience " "and what handlers are most appropriate for their application: if you add " "handlers 'under the hood', you might well interfere with their ability to " "carry out unit tests and deliver logs which suit their requirements." msgstr "" "*ライブラリのロガーには、* :class:`~logging.NullHandler` *以外のハンドラを追" "加しない* ことを強く推奨します。これは、ハンドラの設定が、あなたのライブラリ" "を使うアプリケーション開発者にも伝播するからです。アプリケーション開発者は、" "対象となる聴衆と、そのアプリケーションにどのハンドラが最も適しているかを知っ" "ています。ハンドラを 'ボンネットの中で' 加えてしまうと、ユニットテストをして" "必要に応じたログを送達する能力に干渉しかねません。" #: ../../howto/logging.rst:837 msgid "Logging Levels" msgstr "ロギングレベル" #: ../../howto/logging.rst:839 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 "" "ログレベルの数値は以下の表のように与えられています。これらは基本的に自分でレ" "ベルを定義したい人のためのもので、定義するレベルを既存のレベルの間に位置づけ" "るためには具体的な値が必要になります。もし数値が他のレベルと同じだったら、既" "存の値は上書きされその名前は失われます。" #: ../../howto/logging.rst:846 msgid "Numeric value" msgstr "数値" #: ../../howto/logging.rst:848 msgid "50" msgstr "50" #: ../../howto/logging.rst:850 msgid "40" msgstr "40" #: ../../howto/logging.rst:852 msgid "30" msgstr "30" #: ../../howto/logging.rst:854 msgid "20" msgstr "20" #: ../../howto/logging.rst:856 msgid "10" msgstr "10" #: ../../howto/logging.rst:858 msgid "``NOTSET``" msgstr "``NOTSET``" #: ../../howto/logging.rst:858 msgid "0" msgstr "0" #: ../../howto/logging.rst:861 msgid "" "Levels can also be associated with loggers, being set either by the " "developer or through loading a saved logging configuration. When a logging " "method is called on a logger, the logger compares its own level with the " "level associated with the method call. If the logger's level is higher than " "the method call's, no logging message is actually generated. This is the " "basic mechanism controlling the verbosity of logging output." msgstr "" "レベルはロガーに関連付けることもでき、開発者が設定することも、保存されたログ" "記録設定を読み込む際に設定することもできます。ロガーに対してログ記録メソッド" "が呼び出されると、ロガーは自らのレベルとメソッド呼び出しに関連付けられたレベ" "ルを比較します。ロガーのレベルがメソッド呼び出しのレベルよりも高い場合、実際" "のログメッセージは生成されません。これはログ出力の冗長性を制御するための基本" "的なメカニズムです。" #: ../../howto/logging.rst:868 msgid "" "Logging messages are encoded as instances of the :class:`~logging.LogRecord` " "class. When a logger decides to actually log an event, a :class:`~logging." "LogRecord` instance is created from the logging message." msgstr "" "ログ記録されるメッセージは :class:`~logging.LogRecord` クラスのインスタンスと" "してエンコードされます。ロガーがあるイベントを実際にログ出力すると決定した場" "合、ログメッセージから :class:`~logging.LogRecord` インスタンスが生成されま" "す。" #: ../../howto/logging.rst:872 msgid "" "Logging messages are subjected to a dispatch mechanism through the use of :" "dfn:`handlers`, which are instances of subclasses of the :class:`Handler` " "class. Handlers are responsible for ensuring that a logged message (in the " "form of a :class:`LogRecord`) ends up in a particular location (or set of " "locations) which is useful for the target audience for that message (such as " "end users, support desk staff, system administrators, developers). Handlers " "are passed :class:`LogRecord` instances intended for particular " "destinations. Each logger can have zero, one or more handlers associated " "with it (via the :meth:`~Logger.addHandler` method of :class:`Logger`). In " "addition to any handlers directly associated with a logger, *all handlers " "associated with all ancestors of the logger* are called to dispatch the " "message (unless the *propagate* flag for a logger is set to a false value, " "at which point the passing to ancestor handlers stops)." msgstr "" "ログ記録されるメッセージは、ハンドラ (:dfn:`handlers`) を通してディスパッチ機" "構にかけられます。ハンドラは :class:`Handler` クラスのサブクラスのインスタン" "スで、ログ記録された (:class:`LogRecord` 形式の) メッセージが、そのメッセージ" "の伝達対象となる相手 (エンドユーザ、サポートデスクのスタッフ、システム管理" "者、開発者) に行き着くようにする役割を持ちます。ハンドラには特定の出力先を意" "図された :class:`LogRecord` インスタンスが渡されます。各ロガーは 0 個以上のハ" "ンドラを (:class:`Logger` の :meth:`~Logger.addHandler` メソッド) で関連付け" "ることができます。ロガーに直接関連付けられたハンドラに加えて、\\ *ロガーの上" "位にあるロガーすべてに関連付けられたハンドラ* がメッセージを処理する際に呼び" "出されます (ただしロガーの *propagate* フラグが false 値にセットされている場" "合を除きます。その場合は、祖先ハンドラへの伝搬はそこで止まります)。" #: ../../howto/logging.rst:886 msgid "" "Just as for loggers, handlers can have levels associated with them. A " "handler's level acts as a filter in the same way as a logger's level does. " "If a handler decides to actually dispatch an event, the :meth:`~Handler." "emit` method is used to send the message to its destination. Most user-" "defined subclasses of :class:`Handler` will need to override this :meth:" "`~Handler.emit`." msgstr "" "ロガーと同様に、ハンドラは関連付けられたレベルを持つことができます。ハンドラ" "のレベルはロガーのレベルと同じ方法で、フィルタとして働きます。ハンドラがある" "イベントを実際に処理すると決定した場合、 :meth:`~Handler.emit` メソッドが使わ" "れ、メッセージを出力先に送信します。ほとんどのユーザ定義の :class:`Handler` " "のサブクラスで、この :meth:`~Handler.emit` をオーバライドする必要があるでしょ" "う。" #: ../../howto/logging.rst:895 msgid "Custom Levels" msgstr "カスタムレベル" #: ../../howto/logging.rst:897 msgid "" "Defining your own levels is possible, but should not be necessary, as the " "existing levels have been chosen on the basis of practical experience. " "However, if you are convinced that you need custom levels, great care should " "be exercised when doing this, and it is possibly *a very bad idea to define " "custom levels if you are developing a library*. That's because if multiple " "library authors all define their own custom levels, there is a chance that " "the logging output from such multiple libraries used together will be " "difficult for the using developer to control and/or interpret, because a " "given numeric value might mean different things for different libraries." msgstr "" "独自のレベルを定義することは可能ですが、必須ではなく、実経験上は既存のレベル" "が選ばれます。しかし、カスタムレベルが必要だと確信するなら、レベルの定義には" "多大な注意を払うべきで、*ライブラリの開発の際、カスタムレベルを定義することは" "とても悪いアイデア* になり得ます。これは、複数のライブラリの作者がみな独自の" "カスタムレベルを定義すると、与えられた数値が異なるライブラリで異なる意味にな" "りえるため、開発者がこれを制御または解釈するのが難しくなるからです。" #: ../../howto/logging.rst:910 msgid "Useful Handlers" msgstr "便利なハンドラ" #: ../../howto/logging.rst:912 msgid "" "In addition to the base :class:`Handler` class, many useful subclasses are " "provided:" msgstr "" "基底の :class:`Handler` クラスに加え、多くの便利なサブクラスが提供されていま" "す:" #: ../../howto/logging.rst:915 msgid "" ":class:`StreamHandler` instances send messages to streams (file-like " "objects)." msgstr "" ":class:`StreamHandler` インスタンスは、メッセージをストリーム (ファイル風オブ" "ジェクト) に送ります。" #: ../../howto/logging.rst:918 msgid ":class:`FileHandler` instances send messages to disk files." msgstr "" ":class:`FileHandler` インスタンスは、メッセージをディスクファイルに送ります。" #: ../../howto/logging.rst:920 msgid "" ":class:`~handlers.BaseRotatingHandler` is the base class for handlers that " "rotate log files at a certain point. It is not meant to be instantiated " "directly. Instead, use :class:`~handlers.RotatingFileHandler` or :class:" "`~handlers.TimedRotatingFileHandler`." msgstr "" ":class:`~handlers.BaseRotatingHandler` は、ある地点でログファイルを循環させる" "ハンドラの基底クラスです。これを直接インスタンス化することは意図されていませ" "ん。代わりに、 :class:`~handlers.RotatingFileHandler` や :class:`~handlers." "TimedRotatingFileHandler` を使用してください。" #: ../../howto/logging.rst:925 msgid "" ":class:`~handlers.RotatingFileHandler` instances send messages to disk " "files, with support for maximum log file sizes and log file rotation." msgstr "" ":class:`~handlers.RotatingFileHandler` インスタンスは、メッセージをディスク" "ファイルに送り、最大ログファイル数とログファイル循環をサポートします。" #: ../../howto/logging.rst:928 msgid "" ":class:`~handlers.TimedRotatingFileHandler` instances send messages to disk " "files, rotating the log file at certain timed intervals." msgstr "" ":class:`~handlers.TimedRotatingFileHandler` インスタンスは、メッセージをディ" "スクファイルに送り、ログファイルを特定時間のインターバルで循環します。" #: ../../howto/logging.rst:931 msgid "" ":class:`~handlers.SocketHandler` instances send messages to TCP/IP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" ":class:`~handlers.SocketHandler` インスタンスは、 TCP/IP ソケットにメッセージ" "を送ります。バージョン3.4 から、 Unixドメインソケットもサポートされます。" #: ../../howto/logging.rst:934 msgid "" ":class:`~handlers.DatagramHandler` instances send messages to UDP sockets. " "Since 3.4, Unix domain sockets are also supported." msgstr "" ":class:`~handlers.DatagramHandler` インスタンスは UDP ソケットにメッセージを" "送ります。バージョン 3.4 から、Unix ドメインソケットもサポートされます。" #: ../../howto/logging.rst:937 msgid "" ":class:`~handlers.SMTPHandler` instances send messages to a designated email " "address." msgstr "" ":class:`~handlers.SMTPHandler` インスタンスは、メッセージを指示された email " "アドレスに送ります。" #: ../../howto/logging.rst:940 msgid "" ":class:`~handlers.SysLogHandler` instances send messages to a Unix syslog " "daemon, possibly on a remote machine." msgstr "" ":class:`~handlers.SysLogHandler` インスタンスは、メッセージを、必要ならばリ" "モートマシンの、Unix syslog daemon に送ります。" #: ../../howto/logging.rst:943 msgid "" ":class:`~handlers.NTEventLogHandler` instances send messages to a Windows " "NT/2000/XP event log." msgstr "" ":class:`~handlers.NTEventLogHandler` インスタンスは、メッセージを Windows " "NT/2000/XP イベントログに送ります。" #: ../../howto/logging.rst:946 msgid "" ":class:`~handlers.MemoryHandler` instances send messages to a buffer in " "memory, which is flushed whenever specific criteria are met." msgstr "" ":class:`~handlers.MemoryHandler` インスタンスは、メッセージを、特定の基準が満" "たされる度に流される、メモリ中のバッファに送ります。" #: ../../howto/logging.rst:949 msgid "" ":class:`~handlers.HTTPHandler` instances send messages to an HTTP server " "using either ``GET`` or ``POST`` semantics." msgstr "" ":class:`~handlers.HTTPHandler` インスタンスは、メッセージを、 ``GET`` または " "``POST`` セマンティクスを使って、HTTP サーバに送ります。" #: ../../howto/logging.rst:952 msgid "" ":class:`~handlers.WatchedFileHandler` instances watch the file they are " "logging to. If the file changes, it is closed and reopened using the file " "name. This handler is only useful on Unix-like systems; Windows does not " "support the underlying mechanism used." msgstr "" ":class:`~handlers.WatchedFileHandler` インスタンスは、ロギングする先のファイ" "ルを監視します。ファイルが変更されると、そのファイルは閉じられ、ファイル名を" "使って再び開かれます。このハンドラは Unix 系のシステムにのみ便利です。" "Windows は、使われている基の機構をサポートしていません。" #: ../../howto/logging.rst:957 msgid "" ":class:`~handlers.QueueHandler` instances send messages to a queue, such as " "those implemented in the :mod:`queue` or :mod:`multiprocessing` modules." msgstr "" ":class:`~handlers.QueueHandler` インスタンスは、 :mod:`queue` モジュールや :" "mod:`multiprocessing` モジュールなどで実装されているキューにメッセージを送り" "ます。 instances send messages to a queue, such as those implemented in the :" "mod:`queue` or :mod:`multiprocessing` modules." #: ../../howto/logging.rst:960 msgid "" ":class:`NullHandler` instances do nothing with error messages. They are used " "by library developers who want to use logging, but want to avoid the 'No " "handlers could be found for logger XXX' message which can be displayed if " "the library user has not configured logging. See :ref:`library-config` for " "more information." msgstr "" ":class:`NullHandler` インスタンスは、エラーメッセージに対して何もしません。こ" "れは、ライブラリ開発者がロギングを使いたいが、ライブラリのユーザがロギングを" "設定してなくても 'No handlers could be found for logger XXX' メッセージを表示" "させたくない場合に使われます。詳しい情報は :ref:`library-config` を参照してく" "ださい。" #: ../../howto/logging.rst:966 msgid "The :class:`NullHandler` class." msgstr ":class:`NullHandler` クラス。" #: ../../howto/logging.rst:969 msgid "The :class:`~handlers.QueueHandler` class." msgstr ":class:`~handlers.QueueHandler` クラス。" #: ../../howto/logging.rst:972 msgid "" "The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler` " "classes are defined in the core logging package. The other handlers are " "defined in a sub-module, :mod:`logging.handlers`. (There is also another sub-" "module, :mod:`logging.config`, for configuration functionality.)" msgstr "" "コア logging パッケージで、 :class:`NullHandler`, :class:`StreamHandler` およ" "び :class:`FileHandler` クラスが定義されています。その他のハンドラは、サブモ" "ジュールの :mod:`logging.handlers` で定義されています。(環境設定機能のための" "サブモジュール、 :mod:`logging.config` もあります。)" #: ../../howto/logging.rst:977 msgid "" "Logged messages are formatted for presentation through instances of the :" "class:`Formatter` class. They are initialized with a format string suitable " "for use with the % operator and a dictionary." msgstr "" "ログメッセージは、 :class:`Formatter` クラスのインスタンスを通してフォーマッ" "ト化してから表示されます。このインスタンスは、 % 演算子と辞書で使うのに適切な" "フォーマット文字列で初期化されます。" #: ../../howto/logging.rst:981 msgid "" "For formatting multiple messages in a batch, instances of :class:`~handlers." "BufferingFormatter` can be used. In addition to the format string (which is " "applied to each message in the batch), there is provision for header and " "trailer format strings." msgstr "" "複数のメッセージを一括してフォーマット化するには、 :class:`~handlers." "BufferingFormatter` が使えます。(一連の文字列のそれぞれに適用される) フォー" "マット文字列に加え、ヘッダとトレーラフォーマット文字列も提供されています。" #: ../../howto/logging.rst:986 msgid "" "When filtering based on logger level and/or handler level is not enough, " "instances of :class:`Filter` can be added to both :class:`Logger` and :class:" "`Handler` instances (through their :meth:`~Handler.addFilter` method). " "Before deciding to process a message further, both loggers and handlers " "consult all their filters for permission. If any filter returns a false " "value, the message is not processed further." msgstr "" "ロガーレベルおよび/またはハンドラレベルに基づくフィルタリングで十分でなけれ" "ば、 :class:`Filter` のインスタンスを :class:`Logger` と :class:`Handler` イ" "ンスタンスの両方に (:meth:`~Handler.addFilter` を通して) 加えることができま" "す。メッセージの処理を続ける前に、ロガーもハンドラも、全てのフィルタに許可を" "求めます。フィルタのいずれかが偽値を返したら、メッセージの処理は続けられませ" "ん。" #: ../../howto/logging.rst:993 msgid "" "The basic :class:`Filter` functionality allows filtering by specific logger " "name. If this feature is used, messages sent to the named logger and its " "children are allowed through the filter, and all others dropped." msgstr "" "基本の :class:`Filter` 機能では、特定のロガー名でのフィルタリングをできます。" "この機能が使われると、指名されたロガーに送られたメッセージとその子だけがフィ" "ルタを通り、その他は落とされます。" #: ../../howto/logging.rst:1001 msgid "Exceptions raised during logging" msgstr "ログ記録中に発生する例外" #: ../../howto/logging.rst:1003 msgid "" "The logging package is designed to swallow exceptions which occur while " "logging in production. This is so that errors which occur while handling " "logging events - such as logging misconfiguration, network or other similar " "errors - do not cause the application using logging to terminate prematurely." msgstr "" "logging パッケージは、ログを生成している間に起こる例外を飲み込むように設計さ" "れています。これは、ログ記録イベントを扱っている間に発生するエラー (ログ記録" "の設定ミス、ネットワークまたは他の同様のエラー) によってログ記録を使用するア" "プリケーションが早期に終了しないようにするためです。" #: ../../howto/logging.rst:1008 msgid "" ":class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never " "swallowed. Other exceptions which occur during the :meth:`~Handler.emit` " "method of a :class:`Handler` subclass are passed to its :meth:`~Handler." "handleError` method." msgstr "" ":class:`SystemExit` と :class:`KeyboardInterrupt` 例外は決して飲み込まれませ" "ん。 :class:`Handler` サブクラスの :meth:`~Handler.emit` メソッドの間に起こる" "他の例外は、 :meth:`~Handler.handleError` メソッドに渡されます。" #: ../../howto/logging.rst:1013 msgid "" "The default implementation of :meth:`~Handler.handleError` in :class:" "`Handler` checks to see if a module-level variable, :data:`raiseExceptions`, " "is set. If set, a traceback is printed to :data:`sys.stderr`. If not set, " "the exception is swallowed." msgstr "" ":class:`Handler` の :meth:`~Handler.handleError` のデフォルト実装は、モジュー" "ルレベル変数 :data:`raiseExceptions` が設定されているかどうかチェックします。" "設定されているなら、トレースバックが :data:`sys.stderr` に出力されます。設定" "されていないなら、例外は飲み込まれます。" #: ../../howto/logging.rst:1018 msgid "" "The default value of :data:`raiseExceptions` is ``True``. This is because " "during development, you typically want to be notified of any exceptions that " "occur. It's advised that you set :data:`raiseExceptions` to ``False`` for " "production usage." msgstr "" ":data:`raiseExceptions` のデフォルト値は ``True`` です。これは、開発の間に起" "こるどんな例外についても通常は通知してほしいからです。実運用環境では :data:" "`raiseExceptions` を ``False`` に設定することをお勧めします。" #: ../../howto/logging.rst:1028 msgid "Using arbitrary objects as messages" msgstr "任意のオブジェクトをメッセージに使用する" #: ../../howto/logging.rst:1030 msgid "" "In the preceding sections and examples, it has been assumed that the message " "passed when logging the event is a string. However, this is not the only " "possibility. You can pass an arbitrary object as a message, and its :meth:" "`~object.__str__` method will be called when the logging system needs to " "convert it to a string representation. In fact, if you want to, you can " "avoid computing a string representation altogether - for example, the :class:" "`~handlers.SocketHandler` emits an event by pickling it and sending it over " "the wire." msgstr "" "前の節とそこで挙げた例では、イベントを記録するときに渡されたメッセージが文字" "列であると仮定していました。しかし、これは唯一の可能性ではありません。メッ" "セージとして任意のオブジェクトを渡すことができます。そして、ロギングシステム" "がそのオブジェクトを文字列表現に変換する必要があるとき、オブジェクトの :meth:" "`~object.__str__` メソッドが呼び出されます。実際、そうしたければ、文字列表現" "を計算することを完全に避けることができます - 例えば、 :class:`~handlers." "SocketHandler` は、イベントを pickle してネットワーク上で送信することでログ出" "力します。" #: ../../howto/logging.rst:1041 msgid "Optimization" msgstr "最適化" #: ../../howto/logging.rst:1043 msgid "" "Formatting of message arguments is deferred until it cannot be avoided. " "However, computing the arguments passed to the logging method can also be " "expensive, and you may want to avoid doing it if the logger will just throw " "away your event. To decide what to do, you can call the :meth:`~Logger." "isEnabledFor` method which takes a level argument and returns true if the " "event would be created by the Logger for that level of call. You can write " "code like this::" msgstr "" "message 引数の整形は、必要になるまで延期されます。しかしながら、ログ記録メ" "ソッドに渡す引数を計算するだけでもコストがかかる場合があります。ロガーが単に" "イベントを捨てるなら、その計算を避けたいと考えるかもしれません。どうするかを" "決定するために :meth:`~Logger.isEnabledFor` メソッドを呼ぶことができます。こ" "のメソッドは引数にレベルを取って、そのレベルの呼び出しに対して Logger がイベ" "ントを生成するなら true を返します。このようにコードを書くことができます::" #: ../../howto/logging.rst:1055 msgid "" "so that if the logger's threshold is set above ``DEBUG``, the calls to :func:" "`expensive_func1` and :func:`expensive_func2` are never made." msgstr "" "このようにすると、ロガーの閾値が ``DEBUG`` より上に設定されている場合、 :" "func:`expensive_func1` と :func:`expensive_func2` の呼び出しは行われません。" #: ../../howto/logging.rst:1058 msgid "" "In some cases, :meth:`~Logger.isEnabledFor` can itself be more expensive " "than you'd like (e.g. for deeply nested loggers where an explicit level is " "only set high up in the logger hierarchy). In such cases (or if you want to " "avoid calling a method in tight loops), you can cache the result of a call " "to :meth:`~Logger.isEnabledFor` in a local or instance variable, and use " "that instead of calling the method each time. Such a cached value would only " "need to be recomputed when the logging configuration changes dynamically " "while the application is running (which is not all that common)." msgstr "" "ある種のケースでは、 :meth:`~Logger.isEnabledFor` それ自身があなたが期待する" "よりも高価になる場合があります(たとえば明示的なレベル指定がロガー階層の上位の" "みに設定されていて、ロガーが深くネストされているような場合です)。そのような" "ケース(あるいはタイトなループ内でメソッド呼び出しを避けたい場合)は、 :meth:" "`~Logger.isEnabledFor` 結果をローカルにもしくはインスタンス変数としてキャッ" "シュし、メソッドを毎回呼び出すかわりに使えば良いです。そのようなキャッシュ値" "は、(まったく一般的ではありませんが)ロギング設定がアプリケーション実行中に動" "的に変更された場合にのみ再計算が必要でしょう。" #: ../../howto/logging.rst:1067 msgid "" "There are other optimizations which can be made for specific applications " "which need more precise control over what logging information is collected. " "Here's a list of things you can do to avoid processing during logging which " "you don't need:" msgstr "" "これ以外にも、どんなログ情報が集められるかについてより正確なコントロールを必" "要とする、特定のアプリケーションでできる最適化があります。これは、ログ記録の" "間の不要な処理を避けるためにできることのリストです:" #: ../../howto/logging.rst:1073 msgid "What you don't want to collect" msgstr "不要な情報" #: ../../howto/logging.rst:1073 msgid "How to avoid collecting it" msgstr "それを避ける方法" #: ../../howto/logging.rst:1075 msgid "Information about where calls were made from." msgstr "呼び出しがどこから行われたかに関する情報。" #: ../../howto/logging.rst:1075 msgid "" "Set ``logging._srcfile`` to ``None``. This avoids calling :func:`sys." "_getframe`, which may help to speed up your code in environments like PyPy " "(which can't speed up code that uses :func:`sys._getframe`), if and when " "PyPy supports Python 3.x." msgstr "" "``logging._srcfile`` を ``None`` にする。このことにより :func:`sys." "_getframe` 呼び出しを避けることが出来、PyPy のような環境(:func:`sys." "_getframe` の高速化が出来ない)において高速化の役に立ちます。PyPy が Python 3." "x をサポートすれば、ですが。" #: ../../howto/logging.rst:1083 msgid "Threading information." msgstr "スレッド情報。" #: ../../howto/logging.rst:1083 msgid "Set ``logging.logThreads`` to ``0``." msgstr "``logging.logThreads`` を ``0`` にする。" #: ../../howto/logging.rst:1085 msgid "Process information." msgstr "プロセス情報。" #: ../../howto/logging.rst:1085 msgid "Set ``logging.logProcesses`` to ``0``." msgstr "``logging.logProcesses`` を ``0`` にする。" #: ../../howto/logging.rst:1088 msgid "" "Also note that the core logging module only includes the basic handlers. If " "you don't import :mod:`logging.handlers` and :mod:`logging.config`, they " "won't take up any memory." msgstr "" "また、コア logging モジュールが基本的なハンドラだけを含んでいることに注意して" "ください。 :mod:`logging.handlers` と :mod:`logging.config` をインポートしな" "ければ、余分なメモリを消費することはありません。" #: ../../howto/logging.rst:1095 msgid "Module :mod:`logging`" msgstr ":mod:`logging` モジュール" #: ../../howto/logging.rst:1095 msgid "API reference for the logging module." msgstr "logging モジュールの API リファレンス。" #: ../../howto/logging.rst:1098 msgid "Module :mod:`logging.config`" msgstr ":mod:`logging.config` モジュール" #: ../../howto/logging.rst:1098 msgid "Configuration API for the logging module." msgstr "logging モジュールの環境設定 API です。" #: ../../howto/logging.rst:1101 msgid "Module :mod:`logging.handlers`" msgstr ":mod:`logging.handlers` モジュール" #: ../../howto/logging.rst:1101 msgid "Useful handlers included with the logging module." msgstr "logging モジュールに含まれる、便利なハンドラです。" #: ../../howto/logging.rst:1103 msgid ":ref:`A logging cookbook `" msgstr ":ref:`ロギングクックブック `"