Contents Up Previous Next 原文へのリンク

ログ関数

Log functions

これらの関数で様々なロギング機能を提供します(詳細は「ログクラスの概要」をご覧下さい)。 これらは(暗黙的に)現在使用しているログをターゲットにしています。ですから、ログターゲットが(プログラムの始めにwxWidgetsにインストールされた)標準的なものでないのなら、ここにある記述は適用されないかもしれません。
These functions provide a variety of logging functions: see Log classes overview for further information. The functions use (implicitly) the currently active log target, so their descriptions here may not apply if the log target is not the standard one (installed by wxWidgets in the beginning of the program).

Include files

<wx/log.h>

::wxDebugMsg
::wxError
::wxFatalError
::wxLogError
::wxLogFatalError
::wxLogWarning
::wxLogMessage
::wxLogVerbose
::wxLogStatus
::wxLogSysError
::wxLogDebug
::wxLogTrace
::wxSafeShowMessage
::wxSysErrorCode
::wxSysErrorMsg
WXTRACE
WXTRACELEVEL
::wxTrace
::wxTraceLevel


::wxDebugMsg

void wxDebugMsg(const wxString& fmt, ...)

NB: この関数は、特にログ関数wxLogDebugに 取って代わられて、今や時代遅れです。
NB: This function is now obsolete, replaced by Log functions and wxLogDebug in particular.

デバックメッセージを表示すると、Windows環境下ではデバッガのコマンドウィンドウに表示されます。 UNIX環境下では標準エラー出力に出力されます。
Display a debugging message; under Windows, this will appear on the debugger command window, and under Unix, it will be written to standard error.

構文は printf と全く同じです。 書式と個数可変の引数を渡します。
The syntax is identical to printf: pass a format string and a variable list of arguments.

Tip: Windows環境下で、 デバッグウィンドウにメッセージが表示される前にアプリケーションがクラッシュした場合は、 全てのwxDebugMsgを呼出し後 wxYield(処理の明け渡し)を呼び出して下さい。 wxDebugMsg は WIN32s環境下では(少なくとも Watcom C++では)壊れているようですので、 代わりにメッセージを再編集して OutputDebugString を使って下さい。
Tip: under Windows, if your application crashes before the message appears in the debugging window, put a wxYield call after each wxDebugMsg call. wxDebugMsg seems to be broken under WIN32s (at least for Watcom C++): preformat your messages and use OutputDebugString instead.

Include files

<wx/utils.h>


::wxError

void wxError(const wxString& msg, const wxString& title = "wxWidgets Internal Error")

NB: この関数は今や時代遅れです。どうか代わりに wxLogError を使ってください。
NB: This function is now obsolete, please use wxLogError instead.

msg を表示して処理を継続します。これにより、UNIX環境下では標準エラー出力に出力され、 Windows環境下ではメッセージボックスが表示されます。wxWidgetsの内部エラーに使われます。 wxFatalErrorもご覧下さい。
Displays msg and continues. This writes to standard error under Unix, and pops up a message box under Windows. Used for internal wxWidgets errors. See also wxFatalError.

Include files

<wx/utils.h>


::wxFatalError

void wxFatalError(const wxString& msg, const wxString& title = "wxWidgets Fatal Error")

NB: この関数は今や時代遅れです。どうか代わりに wxLogError を使ってください。
NB: This function is now obsolete, please use wxLogError instead.

msg を表示して処理を終了します。これにより、UNIX環境下では標準エラー出力に出力され、 Windows環境下ではメッセージボックスが表示されます。wxWidgetsの致命的な内部エラーに使われます。 wxErrorもご覧下さい。
Displays msg and exits. This writes to standard error under Unix, and pops up a message box under Windows. Used for fatal internal wxWidgets errors. See also wxError.

Include files

<wx/utils.h>


::wxLogError

void wxLogError(const char *formatString, ...)

void wxVLogError(const char *formatString, va_list argPtr)

この関数はエラーメッセージ(すなわちユーザーに見せなくてはならないメッセージ)のために使われます。 デフォルトの処理はユーザー通知用にメッセージボックスを表示します。
The functions to use for error messages, i.e. the messages that must be shown to the user. The default processing is to pop up a message box to inform the user about it.


::wxLogFatalError

void wxLogFatalError(const char *formatString, ...)

void wxVLogFatalError(const char *formatString, va_list argPtr)

wxLogError に似ていますが、終了コードに「3」を返してプログラムを終了します。 標準関数の abort() を使用しても、同じコードを返して処理を終了します。
Like wxLogError, but also terminates the program with the exit code 3. Using abort() standard function also terminates the program with this exit code.


::wxLogWarning

void wxLogWarning(const char *formatString, ...)

void wxVLogWarning(const char *formatString, va_list argPtr)

警告用 - これは通常ユーザーに見せますが、処理は中断しません。
For warnings - they are also normally shown to the user, but don't interrupt the program work.


::wxLogMessage

void wxLogMessage(const char *formatString, ...)

void wxVLogMessage(const char *formatString, va_list argPtr)

全ての正常なインフォメーションメッセージ用。デフォルトでメッセージボックスを表示します(変更は可能)。 注意すべきことは、標準的な動作では後から何らかのエラーが出た場合にはインフォメーションメッセージは表示されない、 つまり後から発生したエラーメッセージが先に起こっているインフォメーションメッセージを無意味なものにしてしまうということです。
For all normal, informational messages. They also appear in a message box by default (but it can be changed). Notice that the standard behaviour is to not show informational messages if there are any errors later - the logic being that the later error messages make the informational messages preceding them meaningless.


::wxLogVerbose

void wxLogVerbose(const char *formatString, ...)

void wxVLogVerbose(const char *formatString, va_list argPtr)

verbose(冗長)表示用。通常は出力されませんが、ユーザーがプログラムのもっと詳細な進行状況を見たい場合には作動されるかもしれません。 (一方、同じ機能で紛らわしい名前なのが wxLogInfoです。)
「wxLogInfo」がどんなものか見つけられなかったため、この部分の訳は怪しい。
For verbose output. Normally, it is suppressed, but might be activated if the user wishes to know more details about the program progress (another, but possibly confusing name for the same function is wxLogInfo).


::wxLogStatus

void wxLogStatus(wxFrame *frame, const char *formatString, ...)

void wxVLogStatus(wxFrame *frame, const char *formatString, va_list argPtr)

void wxLogStatus(const char *formatString, ...)

void wxVLogStatus(const char *formatString, va_list argPtr)

これらの関数でメッセージをロギングすると、「frame」か、 (この関数のバージョン2を使用した場合のデフォルトで)最上位ウィンドウのステータスバーに表示されます。
Messages logged by these functions will appear in the statusbar of the frame or of the top level application window by default (i.e. when using the second version of the functions).

メッセージ表示先となるフレームにステータスバーが存在しなければ、メッセージは失われます。
If the target frame doesn't have a statusbar, the message will be lost.


::wxLogSysError

void wxLogSysError(const char *formatString, ...)

void wxVLogSysError(const char *formatString, va_list argPtr)

大抵はwxWidgets自身に使われていますが、システムコール(API関数)失敗の後にエラーをロギングするのに便利かもしれません。 それは直近のシステムエラーコードや対応するメッセージと同様に、指定されたメッセージテキストをログに出力します (システムエラーコード(errno)や ::GetLastError() は、環境に依存します)。この関数の2番目の書式では、明示的にエラーコードを最初の引数とみなします。
Mostly used by wxWidgets itself, but might be handy for logging errors after system call (API function) failure. It logs the specified message text as well as the last system error code (errno or ::GetLastError() depending on the platform) and the corresponding error message. The second form of this function takes the error code explicitly as the first argument.

See also

wxSysErrorCode, wxSysErrorMsg


::wxLogDebug

void wxLogDebug(const char *formatString, ...)

void wxVLogDebug(const char *formatString, va_list argPtr)

正真正銘のデバック出力用の関数です。これはデバックモード(「__WXDEBUG__」が定義されている場合)でのみ動作し、 リリースモード(その他の場合)では展開されません。
The right functions for debug output. They only do something in debug mode (when the preprocessor symbol __WXDEBUG__ is defined) and expand to nothing in release mode (otherwise).


::wxLogTrace

void wxLogTrace(const char *formatString, ...)

void wxVLogTrace(const char *formatString, va_list argPtr)

void wxLogTrace(const char *mask, const char *formatString, ...)

void wxVLogTrace(const char *mask, const char *formatString, va_list argPtr)

void wxLogTrace(wxTraceMask mask, const char *formatString, ...)

void wxVLogTrace(wxTraceMask mask, const char *formatString, va_list argPtr)

wxLogDebugのように、トレース関数もデバックビルド時にだけ動作し、リリースビルド時には展開されません。 これを別個の関数にした理由は、通常トレースメッセージは大量に出力されるため、他のデバックメッセージと分離することに 意味があるだろうからです。
As wxLogDebug, trace functions only do something in debug build and expand to nothing in the release one. The reason for making it a separate function from it is that usually there are a lot of trace messages, so it might make sense to separate them from other debug messages.

トレースメッセージもいくつかのカテゴリに分類できます。この関数のバージョン2・3では、wxLogmask 機能が使用可能であれば、ただメッセージを記録するだけです。これはトレースマスクを変更する(ランタイム中も可能です)ことに よって、他を排除した「あるオペレーションについて」という選択的なトレースを許したものです。 
The trace messages also usually can be separated into different categories and the second and third versions of this function only log the message if the mask which it has is currently enabled in wxLog. This allows to selectively trace only some operations and not others by changing the value of the trace mask (possible during the run-time).

2番目の関数(stringマスクを持っているもの)では、メッセージは AddTraceMaskの呼び出しによってずっと使用可能状態だった場合に限り、ログに記録されます。

wxWidgetsで事前に定義されている文字列型のトレースマスクは以下のとおりです。

For the second function (taking a string mask), the message is logged only if the mask has been previously enabled by the call to AddTraceMask. The predefined string trace masks used by wxWidgets are:

関数の3番目のバージョンでは、もし mask に対応している全てのビットがwxLogのトレースマスクにセットされていれば(これは、SetTraceMaskでセットできる)、 ただメッセージを出力するだけです。このバージョンは前述のバージョンほど柔軟ではありません。なぜならユーザーが手軽にトレースマスクを定義することを許していないからです。 このバージョンがけなされて、文字列型のトレースマスクが好まれる理由はここにあります。
The third version of the function only logs the message if all the bit corresponding to the mask are set in the wxLog trace mask which can be set by SetTraceMask. This version is less flexible than the previous one because it doesn't allow defining the user trace masks easily - this is why it is deprecated in favour of using string trace masks.


::wxSafeShowMessage

void wxSafeShowMessage(const wxString& title, const wxString& text)

この関数はアプリケーションの初期化前やその他の奇妙な状態(クラッシュ等)でも安全に、ユーザーにメッセージを表示するものです。Windows環境下では、(もしかしたら呼び出すのが危険かもしれない) wxMessageBox の代わりにプラットホーム本来のダイアログを使ってメッセージを表示します。 他の環境では、単純にタイトルを接頭語としたメッセージを標準出力に出力します。
This function shows a message to the user in a safe way and should be safe to call even before the application has been initialized or if it is currently in some other strange state (for example, about to crash). Under Windows this function shows a message box using a native dialog instead of wxMessageBox (which might be unsafe to call), elsewhere it simply prints the message to the standard output using the title as prefix.

Parameters

title

text

See also

wxLogFatalError

Include files

<wx/log.h>


::wxSysErrorCode

unsigned long wxSysErrorCode()

直前のシステムコールのエラーコードを取得する。この関数はUnix環境では errno を使用し、Win32環境では GetLastError を使用する。
Returns the error code from the last system call. This function uses errno on Unix platforms and GetLastError under Win32.

See also

wxSysErrorMsg, wxLogSysError


::wxSysErrorMsg

const wxChar * wxSysErrorMsg(unsigned long errCode = 0)

引数で与えらシステムエラーコードに対応するエラーメッセージを取得する。もし errCode に 0(デフォルト)をセットすれば、(wxSysErrorCodeと同様に)直前のエラーコードを使用する。
Returns the error message corresponding to the given system error code. If errCode is 0 (default), the last error code (as returned by wxSysErrorCode) is used.

See also

wxSysErrorCode, wxLogSysError


WXTRACE

Include files

<wx/object.h>

WXTRACE(formatString, ...)

NB: このマクロはいまや時代遅れで、Log functionsに取って代わられています。
NB: This macro is now obsolete, replaced by Log functions.

wxTraceをprintf形式の可変引数の書式で呼び出します。出力先は現在のoutput stream となります(詳細はwxDebugContextを参照のこと)。
Calls wxTrace with printf-style variable argument syntax. Output is directed to the current output stream (see wxDebugContext).

Include files

<wx/memory.h>


WXTRACELEVEL

WXTRACELEVEL(level, formatString, ...)

NB: この関数はいまや時代遅れで、Log functionsに取って代わられています。
NB: This function is now obsolete, replaced by Log functions.

wxTraceLevelをprintf形式の可変引数の書式で呼び出します。出力先は現在のoutput stream となります(詳細はwxDebugContextを参照のこと)。最初の引数はこの情報にふさわしいレベルであるべきです。もし wxDebugContext::GetLevel の戻り値がこの値以上ならそれは出力されるだけでしょう。
Calls wxTraceLevel with printf-style variable argument syntax. Output is directed to the current output stream (see wxDebugContext). The first argument should be the level at which this information is appropriate. It will only be output if the level returned by wxDebugContext::GetLevel is equal to or greater than this value.

Include files

<wx/memory.h>


::wxTrace

void wxTrace(const wxString& fmt, ...)

NB: この関数はいまや時代遅れで、Log functionsに取って代わられています。
NB: This function is now obsolete, replaced by Log functions.

引数としてprintf形式の可変引数の書式を取得します。出力先は現在のoutput stream となります(詳細はwxDebugContextを参照のこと)。
Takes printf-style variable argument syntax. Output is directed to the current output stream (see wxDebugContext).

Include files

<wx/memory.h>


::wxTraceLevel

void wxTraceLevel(int level, const wxString& fmt, ...)

NB: この関数はいまや時代遅れで、Log functionsに取って代わられています。
NB: This function is now obsolete, replaced by Log functions.

引数としてprintf形式の可変引数の書式を取得します。出力先は現在のoutput stream となります(詳細はwxDebugContextを参照のこと)。最初の引数はこの情報にふさわしいレベルであるべきです。もし wxDebugContext::GetLevel の戻り値がこの値以上ならそれは出力されるだけでしょう。
Takes printf-style variable argument syntax. Output is directed to the current output stream (see wxDebugContext). The first argument should be the level at which this information is appropriate. It will only be output if the level returned by wxDebugContext::GetLevel is equal to or greater than this value.

Include files

<wx/memory.h>