libzypp: zyppng::log::formatter< T, Enable > Struct Template Reference

libzypp 17.38.6

zyppng::log::formatter< T, Enable > Struct Template Reference

Primary trait for object formatting. More...

## Detailed Description

template<typename T, typename Enable = void>
struct zyppng::log::formatter< T, Enable >

Primary trait for object formatting.

To support a type `T` in the log layer, you must provide a specialization of this struct. The specialization is valid if it implements at least one of the two static `stream` signatures.

# The Interface Contract

## 1. Context-Aware (For SAT Handles/IDs)

static std::ostream& stream(std::ostream& os, const ContextRef& ctx, const T& obj);

Use this for objects that require system state (like a `Pool` or Config) to be resolved.

## 2. Context-Independent (For Self-contained Values)

static std::ostream& stream(std::ostream& os, const T& obj);

Use this for objects that own their data (like `Arch` or `Edition`).

# implementation Example

template <>
struct formatter<sat::SolvableId> {
static std::ostream& stream(std::ostream& os, const ContextRef& ctx, sat::SolvableId id) {
return os << ctx.pool().getName(id);
}
};
zypp::sat
Libsolv interface
zyppng::log::formatter
Primary trait for object formatting.
Definition format.h:67

Template Parameters

  T | The logic type to be formatted.

Note
  If both signatures are provided, `log::view(ctx, obj)` will prioritize the Context-Aware version.

Definition at line 67 of file format.h.

The documentation for this struct was generated from the following file:

- zypp/ng/log/format.h