Kind: Interface
Source: packages/microservices/external/kafka.interface.ts
Part of: Microservices
LogEntry defines the structured payload used to represent a log message in the Kafka microservices integration. It combines routing and classification metadata (namespace, level, and label) with the actual logger content in log, enabling consistent log publishing and consumption across services.
Properties
| Property | Type |
|---|---|
namespace | string |
level | logLevel |
label | string |
log | LoggerEntryContent |
Diagram
mermaidgraph LR A[Application or Microservice] --> B[LogEntry] B --> C[namespace: string] B --> D[level: logLevel] B --> E[label: string] B --> F[log: LoggerEntryContent] B --> G[Kafka Logging Pipeline]
Usage
tsimport type { LogEntry } from './kafka.interface';
const logEntry: LogEntry = {
namespace: 'payments-service',
level: 'error',
label: 'payment-processing',
log: {
message: 'Failed to process payment',
transactionId: 'txn_12345',
error: 'Card authorization declined',
},
};
// Example: send the structured entry through a Kafka producer.
await kafkaProducer.send({
topic: 'service-logs',
messages: [{ value: JSON.stringify(logEntry) }],
});
AI Coding Instructions
- Populate
namespacewith a stable service or application identifier so consumers can filter logs reliably. - Use valid
logLevelvalues rather than arbitrary strings when settinglevel. - Keep
labelconcise and action-oriented, such asdatabase-queryorpayment-processing. - Store structured context in
loginstead of serializing important metadata into a message string. - Preserve the full
LogEntryshape when publishing to or consuming from Kafka topics.
Was this page helpful?