40 lines
888 B
Dart
40 lines
888 B
Dart
|
import 'dart:developer';
|
||
|
|
||
|
import 'package:angel3_mq/mq.dart';
|
||
|
|
||
|
final class DebugLogger with ConsumerMixin {
|
||
|
DebugLogger() {
|
||
|
MQClient.instance.declareExchange(
|
||
|
exchangeName: 'logs',
|
||
|
exchangeType: ExchangeType.direct,
|
||
|
);
|
||
|
_queueName = MQClient.instance.declareQueue('debug');
|
||
|
}
|
||
|
|
||
|
late final String _queueName;
|
||
|
|
||
|
void startListening() {
|
||
|
MQClient.instance.bindQueue(
|
||
|
queueId: _queueName,
|
||
|
exchangeName: 'logs',
|
||
|
bindingKey: 'info',
|
||
|
);
|
||
|
MQClient.instance.bindQueue(
|
||
|
queueId: _queueName,
|
||
|
exchangeName: 'logs',
|
||
|
bindingKey: 'warning',
|
||
|
);
|
||
|
MQClient.instance.bindQueue(
|
||
|
queueId: _queueName,
|
||
|
exchangeName: 'logs',
|
||
|
bindingKey: 'error',
|
||
|
);
|
||
|
subscribe(
|
||
|
queueId: _queueName,
|
||
|
callback: (Message message) {
|
||
|
log('Debug Logger recieved: ${message.payload}');
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
}
|