This class can be used to display messages to the user.
More...
#include <ilserver/logfile.h>
Inherits IlsIndenter.
|
static void | AddFilter (LogfileFilterFunc, IlsAny=0) |
| Adds a callback to the list of callbacks to filter error messages.
|
|
static void | AddRedirect (LogfileMessageFunc, IlsAny=0) |
| Adds a callback to the list of callbacks to redirect error messages.
|
|
static IlsLogLevel | GetLogLevel () |
| Gets the current logging level that is used to control whether or not a message is reported to the user. More...
|
|
static IlsString | GetMsgPrefix () |
| Gets the current message prefix, if any. More...
|
|
static IlsBoolean | RemoveFilter (LogfileFilterFunc, IlsAny=0) |
| Removes a callback from the list of callbacks to filter error messages.
|
|
static IlsBoolean | RemoveRedirect (LogfileMessageFunc, IlsAny=0) |
| Removes a callback from the list of callbacks to redirect error messages.
|
|
static void | SetFilter (LogfileFilterFunc=0, IlsAny=0) |
| Sets, or unsets if the callback is zero, the callback to filter error messages.
|
|
static IlsBoolean | SetLogfile (const IlsString &fileName=IlsString::Null, IlsBoolean logAndOutput=IlsFalse, IlsBoolean appendToLog=IlsFalse) |
| Redirects all messages to a file. More...
|
|
static IlsLogLevel | SetLogLevel (IlsLogLevel level) |
| Sets the current logging level to the value of the argument level for all new messages. More...
|
|
static void | SetMsgPrefix (const IlsString &prefix) |
| Sets a prefix to all messages. More...
|
|
static void | SetPrintMessagesInFull (IlsBoolean inFull) |
| Chooses to print the complete message, including the prefix information. More...
|
|
static void | SetRedirect (LogfileMessageFunc=0, IlsAny=0) |
| Sets, or unsets if the callback is zero, the callback to redirect error messages.
|
|
static void | ThrowExceptionOnExit (IlsBoolean=IlsTrue) |
| Makes library throw an exception of class IlsOnExitException which derives from IlsException ), rather than calling exit() or abort() . More...
|
|
|
ILSIMPORT IlsLogfile & | dec (IlsLogfile &) |
| Sets the printing base for integers to decimal. More...
|
|
ILSIMPORT IlsLogfile & | hex (IlsLogfile &) |
| Sets the printing base for integers to hexadecimal. More...
|
|
ILSIMPORT IlsLogfile & | IlsDebug (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of a debug message. More...
|
|
ILSIMPORT void | IlsEOM (IlsLogfile &) |
| Appends a new line to the message and sends the message. More...
|
|
ILSIMPORT IlsLogfile & | IlsError (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of an error. More...
|
|
ILSIMPORT IlsLogfile & | IlsFatalError (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of a fatal error. More...
|
|
ILSIMPORT IlsLogfile & | IlsInfo (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of an information message. More...
|
|
ILSIMPORT IlsLogfile & | IlsInternalError (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of a internal error. More...
|
|
ILSIMPORT IlsLogfile & | IlsMsg (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of a plain message. More...
|
|
ILSIMPORT IlsLogfile & | IlsWarn (IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &) |
| Creates an instance of a warning. More...
|
|
ILSIMPORT IlsLogfile & | oct (IlsLogfile &) |
| Sets the printing base for integers to octal. More...
|
|
ILSIMPORT IlsLogfile & | restore (IlsLogfile &) |
| Restores the printing base to its old value. More...
|
|
This class can be used to display messages to the user.
Library: server
and mvcomp
It can be used in a multithread environment as it is multithread-safe. Also, this class buffers messages, so that messages posted from different threads do not get mixed together in the output. A message is not sent until the IlsEOM
function is encountered. A message that does not end with IlsEOM
is never posted.
- See also
IlsException
, IlsInit()
, IlsLogfile::MsgDescription
.
◆ LogfileFilterFunc
This callback can be used to filter out messages that you want displayed to the user.
If any filter returns IlsFalse
for a message, this message is not displayed or logged. See the member functions under Filtering Messages.
◆ LogfileMessageFunc
This callback is used by the message-redirecting methods to trap all messages from the class IlsLogfile
.
See the member functions under Redirecting Error Messages to the Application.
◆ GetLogLevel()
Gets the current logging level that is used to control whether or not a message is reported to the user.
The default logging level is ILS_LOG_WARNING
, which means that all messages, except debug messages, are reported.
- Returns
- the log level
◆ GetMsgPrefix()
static IlsString IlsLogfile::GetMsgPrefix |
( |
| ) |
|
|
static |
Gets the current message prefix, if any.
- Returns
- current message prefix
◆ SetLogfile()
Redirects all messages to a file.
Depending on how the logAndOutput and appendToLog Boolean parameters are set, the messages can be redirected:
- either uniquely to a file,
- or to a file and to the normal output stream.
- In addition, the output can be appended to the logfile if desired. If the output is redirected to a file and the file already exists, the existing file is removed provided that the argument appendToLog is set to
IlsFalse
.
This function can also be set via the environment variables ILS_LOGFILE
, ILS_LOGFILE_ONLY
and ILS_LOGFILE_APPEND
.
- Setting
ILS_LOGFILE_ONLY
causes the output to go only to the logfile specified.
- Setting
ILS_LOGFILE
causes the output to go to the logfile and to the normal output stream.
- Setting
ILS_LOGFILE_APPEND
causes the output to be appended to the logfile.
This function will expand the string found so as to substitute the current process identifier if requested. If the string contains the sequence PID%
,it will be replaced with the current process identifier. This mechanism allows several clients to write to different logfiles via the environment variable.
- Parameters
-
fileName | log file name |
logAndOutput | if equal to
IlsTrue: log to file and to output
IlsFalse: log only to file.
|
appendToLog | IlsTrue to append to or IlsFalse to erase the log file when it exists |
◆ SetLogLevel()
Sets the current logging level to the value of the argument level for all new messages.
This function returns the old logging level. It can be used to filter what level of messages are reported to the user. Refer to the type IlsLogLevel
to know the relative order of messages.
- Parameters
-
- Returns
- old log level
◆ SetMsgPrefix()
static void IlsLogfile::SetMsgPrefix |
( |
const IlsString & |
prefix | ) |
|
|
static |
Sets a prefix to all messages.
- Parameters
-
◆ SetPrintMessagesInFull()
static void IlsLogfile::SetPrintMessagesInFull |
( |
IlsBoolean |
inFull | ) |
|
|
static |
Chooses to print the complete message, including the prefix information.
By default, the inFull parameter is set to IlsFalse
.
◆ ThrowExceptionOnExit()
static void IlsLogfile::ThrowExceptionOnExit |
( |
IlsBoolean |
= IlsTrue | ) |
|
|
static |
Makes library throw an exception of class IlsOnExitException
which derives from IlsException
), rather than calling exit()
or abort()
.
This function is useful when it is important to avoid a blunt application exit. In this case, call the function ThrowExceptionOnExit(IlsTrue)
and catch any exceptions in the main thread (or secondary threads if any) as shown in the code samples below.
try {
run();
} catch (...) {
}
◆ dec
Sets the printing base for integers to decimal.
An example of its use is shown below:
◆ hex
Sets the printing base for integers to hexadecimal.
An example of its use is shown below:
◆ IlsDebug
Creates an instance of a debug message.
Debug messages are not normally posted to the user. However, if you want to have them posted, set the log level (via a call to the static member function SetLogLevel()
) to ILS_LOG_DEBUG
.
An example of its use is shown below:
◆ IlsEOM
Appends a new line to the message and sends the message.
A message that does not end with IlsEOM
is never posted.
◆ IlsError
Creates an instance of an error.
An error will not exit after the message has been displayed.
An example of its use is shown below:
◆ IlsFatalError
Creates an instance of a fatal error.
A fatal error will call exit
after the message has been displayed.
An example of its use is shown below:
◆ IlsInfo
Creates an instance of an information message.
An example of its use is shown below:
◆ IlsInternalError
Creates an instance of a internal error.
An internal error will call abort
after the message has been displayed.
An example of its use is shown below:
◆ IlsMsg
Creates an instance of a plain message.
An example of its use is shown below:
◆ IlsWarn
Creates an instance of a warning.
An example of its use is shown below:
◆ oct
Sets the printing base for integers to octal.
An example of its use is shown below:
◆ restore
Restores the printing base to its old value.
Only the last value is saved so calling the restore()
function twice will not work.
An example of its use is shown below:
<<
" for count " << count <<
IlsEOM;
friend ILSIMPORT IlsLogfile & IlsInfo(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of an information message.
This class is the base class for all exceptions thrown in the Server library.
Definition: except.h:57
friend ILSIMPORT IlsLogfile & IlsFatalError(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of a fatal error.
friend ILSIMPORT IlsLogfile & IlsError(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of an error.
static void ThrowExceptionOnExit(IlsBoolean=IlsTrue)
Makes library throw an exception of class IlsOnExitException which derives from IlsException),...
friend ILSIMPORT IlsLogfile & hex(IlsLogfile &)
Sets the printing base for integers to hexadecimal.
friend ILSIMPORT IlsLogfile & oct(IlsLogfile &)
Sets the printing base for integers to octal.
friend ILSIMPORT IlsLogfile & restore(IlsLogfile &)
Restores the printing base to its old value.
friend ILSIMPORT IlsLogfile & IlsWarn(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of a warning.
friend ILSIMPORT void IlsEOM(IlsLogfile &)
Appends a new line to the message and sends the message.
friend ILSIMPORT IlsLogfile & IlsMsg(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of a plain message.
friend ILSIMPORT IlsLogfile & IlsDebug(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of a debug message.
This exception can be thrown by the log file instead of calling exit or abort on a fatal or internal ...
Definition: logfile.h:1276
friend ILSIMPORT IlsLogfile & dec(IlsLogfile &)
Sets the printing base for integers to decimal.
friend ILSIMPORT IlsLogfile & IlsInternalError(IlsLogfile::CategoryId, IlsLogfile::MessageId, const IlsString &, const IlsString &)
Creates an instance of a internal error.