/***** License -------------- Copyright © 2020-2025 Mojaloop Foundation The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Contributors -------------- This is the official list of the Mojaloop project contributors for this file. Names of the original copyright holders (individuals or organizations) should be listed with a '*' in the first column. People who have contributed from an organization can be listed under the organization that actually holds the copyright for their contributions (see the Mojaloop Foundation for an example). Those individuals should have their names indented and be marked with a '-'. Email address can be added optionally within square brackets . * Mojaloop Foundation - Name Surname - Ramiro González Maciel - Valentin Genev -------------- ******/ /** * Example showing how to use EventLogger from TypeScript * */ import {Tracer} from "../Tracer" import { EventMessage, EventMetadata, LogEventTypeAction, EventStatusType, TypeMessageMetadata, LogEventAction } from "../model/EventMessage" const now = new Date(); const event: EventMessage = { // Creates EventMessage type object, which can be sent to the event recorders and further to sidecar and event stream processor and the monitoring environment. from: "noresponsepayeefsp", to: "payerfsp", id: "aa398930-f210-4dcd-8af0-7c769cea1660", content: { headers: { "content-type": "application/vnd.interoperability.transfers+json;version=1.0", date: "2019-05-28T16:34:41.000Z", "fspiop-source": "noresponsepayeefsp", "fspiop-destination": "payerfsp", priority: 100, blocking: false }, payload: "data:application/vnd.interoperability.transfers+json;version=1.0;base64,ewogICJmdWxmaWxtZW50IjogIlVObEo5OGhaVFlfZHN3MGNBcXc0aV9VTjN2NHV0dDdDWkZCNHlmTGJWRkEiLAogICJjb21wbGV0ZWRUaW1lc3RhbXAiOiAiMjAxOS0wNS0yOVQyMzoxODozMi44NTZaIiwKICAidHJhbnNmZXJTdGF0ZSI6ICJDT01NSVRURUQiCn0", data: { str1: 'Hi world', number1: 12345, date1: now, bool1: true, nil1: null, undef1: undefined, array1: ["Hello", 1234, now, true, null, undefined], child: { str2: 'Hi world', number2: 12345, date2: now, bool2: true, nil2: null, undef2: undefined, array2: ["Hello", 1234, now, true, null, undefined], } } }, type: "application/json", metadata: { event: EventMetadata.log({ id: "3920382d-f78c-4023-adf9-0d7a4a2a3a2f", action: (new LogEventTypeAction(LogEventAction.debug)).action, // Actions which are available can be generated by the respective methods createdAt: "2019-05-29T23:18:32.935Z", state: { status: EventStatusType.success, code: 0, description: "action successful" }, responseTo: "1a396c07-47ab-4d68-a7a0-7a1ea36f0012" })} as TypeMessageMetadata // metadata with specific type definition } const tracer = Tracer.createSpan('new-span') // Creates new trace with its first span. console.log('app: sending message', JSON.stringify(event, null, 2)) tracer.info(event) // Logs event message with log level info. For the rest of the methods and usecases you can see the js_app.js .then(result => { console.log('app: received back:', JSON.stringify(result, null, 2)) })