m8ty_client_logging
Package overview
Section titled “Package overview”m8ty_client_logging solves this with a standard interface for plain and encrypted frontend log submission, helping teams diagnose issues while supporting protected log transport.
Frontend logging client with support for plain and encrypted log submission.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_logging library to get an idea about the available models and their properties.
Import all needed libraries
Section titled “Import all needed libraries” import 'package:dio/dio.dart'; import 'package:m8ty_client_logging/m8ty_client_logging.dart'; import 'package:m8ty_client_common/m8ty_client_common.dart'; import 'package:built_collection/built_collection.dart';Client Setup
Section titled “Client Setup”final loggingClient = M8tyClientLogging();loggingClient.setApiKey(m8tyApiKeyAuth, "myApiKey");API Surface
Section titled “API Surface”LoggingApi
Section titled “LoggingApi”| Method | Description |
|---|---|
log |
Frontend logging (plain text) |
logEncrypted |
Frontend logging (encrypted payload) |
getPublicKey |
Retrieve public key for encryption |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Send a log entry to the server
Section titled “Send a log entry to the server” final loggingClient = M8tyClientLogging(); loggingClient.setApiKey(m8tyApiKeyAuth, "myApiKey");
final loggingApi = loggingClient.getLoggingApi();
final logEntry = LogEntryModel((b) => b ..severity = LogSeverityEnumModel.DEBUG ..message = "My log message" ..operation = "executePayment" ..metadata = MapBuilder({'deviceid': '1234', 'appVersion': '1.21'}) ..timestamp = DateTime.now().toUtc() ..resource = "instantpayment" ..stacktrace = StackTrace.current.toString() ..labels = BuiltList.of(['payment', "instant"]).toBuilder(), );
final loggingRequestModel = LoggingRequestModel( (b) => b..logs = BuiltList.of([logEntry]).toBuilder(), );
loggingApi.log(loggingRequestModel: loggingRequestModel);Get public key for encrypted logging
Section titled “Get public key for encrypted logging” final loggingClient = M8tyClientLogging(); loggingClient.setApiKey(m8tyApiKeyAuth, "myApiKey");
final loggingApi = loggingClient.getLoggingApi();
try { final response = await loggingApi.getPublicKey(); print('Public key: ${response.data}'); } on DioException catch (e) { throw Exception( 'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}', ); }© m8ty GmbH 2023 · m8ty.eu
