LibreOffice: sal/log.hxx File Reference

LibreOffice LibreOffice 7.3 SDK C/C++ API Reference

Macros
log.hxx File Reference
`#include "sal/config.h"`
`#include <cstdlib>`
`#include <sstream>`
`#include <string>`
`#include "sal/detail/log.h"`
`#include "sal/saldllapi.h"`
`#include "sal/types.h"`

Go to the source code of this file.

## Macros
#define | SAL_WHERE SAL_DETAIL_WHERE
| A simple macro to create a "file and line number" string. More...
#define | SAL_STREAM(stream) (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream).str())
| A facility for generating temporary string messages by piping items into a C++ std::ostringstream. More...
#define | SAL_INFO(area, stream)
| Produce log entry from stream in the given log area. More...
#define | SAL_INFO_IF(condition, area, stream)
| Produce log entry from stream in the given log area if condition is true. More...
#define | SAL_WARN(area, stream)
| Produce warning entry from stream in the given log area. More...
#define | SAL_WARN_IF(condition, area, stream)
| Produce warning entry from stream in the given log area if condition is true. More...
#define | SAL_DEBUG(stream)
| Produce temporary debugging output from stream. More...
#define | SAL_DEBUG_IF(condition, stream)
| Produce temporary debugging output from stream, if condition is true. More...
#define | SAL_DEBUG_BACKTRACE(stream, backtraceDepth)
| Produce temporary debugging output from stream along with a backtrace of the calling location. More...

## Macro Definition Documentation

## ◆ SAL_DEBUG

#define SAL_DEBUG | ( |  | stream | ) |

Value:
SAL_DETAIL_LOG_STREAM( \
SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, stream)

Produce temporary debugging output from stream.

This macro is meant to be used only while working on code and should never exist in production code.

See basic logging functionality for details.

## ◆ SAL_DEBUG_BACKTRACE

#define SAL_DEBUG_BACKTRACE | ( |  | stream,
|  |  | backtraceDepth
| ) |  |

Value:
do { \
if (sizeof ::sal::detail::getResult( \
::sal::detail::StreamStart() << stream) == 1) \
{ \
::sal_detail_log( \
::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, \
::sal::detail::unwrapStream( \
::sal::detail::StreamStart() << stream), \
backtraceDepth); \
} else { \
::std::ostringstream sal_detail_stream; \
sal_detail_stream << stream; \
::sal::detail::log( \
::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, sal_detail_stream, \
backtraceDepth); \
} \
} while (false)

Produce temporary debugging output from stream along with a backtrace of the calling location.

This macro is meant to be used only while working on code and should never exist in production code.

Parameters

  stream | input stream
  backtraceDepth | a sal_uInt32 value indicating the maximum backtrace depth; zero means no backtrace

See basic logging functionality for details.

## ◆ SAL_DEBUG_IF

#define SAL_DEBUG_IF | ( |  | condition,
|  |  | stream
| ) |  |

Value:
SAL_DETAIL_LOG_STREAM( \
(condition), ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, stream)

Produce temporary debugging output from stream, if condition is true.

This macro is meant to be used only while working on code and should never exist in production code.

See basic logging functionality for details.

## ◆ SAL_INFO

#define SAL_INFO | ( |  | area,
|  |  | stream
| ) |  |

Value:
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, area, \
SAL_WHERE, stream)
SAL_WHERE
#define SAL_WHERE
A simple macro to create a "file and line number" string.
Definition: log.hxx:179

Produce log entry from stream in the given log area.

See basic logging functionality for details.

## ◆ SAL_INFO_IF

#define SAL_INFO_IF | ( |  | condition,
|  |  | area,
|  |  | stream
| ) |  |

Value:
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_INFO && (condition), \
::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)

Produce log entry from stream in the given log area if condition is true.

See basic logging functionality for details.

## ◆ SAL_STREAM

#define SAL_STREAM | ( |  | stream | ) | (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream).str())

A facility for generating temporary string messages by piping items into a C++ std::ostringstream.

This can be useful for example in a call to SAL_INFO when depending on some boolean condition data of incompatible types shall be streamed into the message, as in:

SAL_INFO("foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));

Attention
  For now, this functionality should only be used internally within LibreOffice. It may change again in a future version.

Since
  LibreOffice 3.5

## ◆ SAL_WARN

#define SAL_WARN | ( |  | area,
|  |  | stream
| ) |  |

Value:
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN, area, \
SAL_WHERE, stream)

Produce warning entry from stream in the given log area.

See basic logging functionality for details.

## ◆ SAL_WARN_IF

#define SAL_WARN_IF | ( |  | condition,
|  |  | area,
|  |  | stream
| ) |  |

Value:
SAL_DETAIL_LOG_STREAM( \
SAL_DETAIL_ENABLE_LOG_WARN && (condition), \
::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)

Produce warning entry from stream in the given log area if condition is true.

See basic logging functionality for details.

## ◆ SAL_WHERE

#define SAL_WHERE SAL_DETAIL_WHERE

A simple macro to create a "file and line number" string.

Potentially not only useful within the log framework (where it is used automatically), but also when creating exception messages.

Attention
  For now, this functionality should only be used internally within LibreOffice. It may change again in a future version.

Since
  LibreOffice 3.5