Attributes
Every log method takes the message, followed by two optional objects: context and attributes. Use them to record the data that makes a log message useful to search and filter on later.
contextis data about this log entry. Flare stores it under thelog.contextattribute and shows it in the "Context" section of the log detail view. This is the argument you need most of the time.attributesare added to the log record as they are, next tolog.context. Use them for keys you want stored as separate attributes, such as OpenTelemetry attribute names.
flare.logger.info('Order placed', {
orderId: 'ord_8231',
total: 49.99,
currency: 'EUR',
items: 3,
});
Values can be strings, numbers, booleans, null, arrays, or nested objects. To set attributes, pass a context object first, which can be empty:
flare.logger.warning(
'Validation failed',
{ field: 'email', errors: ['required', 'invalid_format'] },
{ 'form.id': 'signup' },
);
How context and attributes are handled
Context and attributes are frozen at the moment you record the log. The client encodes them immediately, so later changes to the original objects don't affect the buffered entry. Pass the values you want captured at call time.
Context and attributes you set on a log entry apply only to that entry. They are not shared with other logs or with error reports.
Service-wide identity
Set serviceName once through configuration to attach it to every log batch (sent as service.name), rather than passing it per-call:
flare.configure({
enableLogs: true,
serviceName: 'storefront',
});