Skip to content

Commit 62df657

Browse files
committed
Asyncapi: Add debug logs instead of console warn and console errors
1 parent 37f9c50 commit 62df657

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 1.0.3 - TBD
8+
9+
### Changed
10+
11+
- Replaced `console.warn` statements with `cds.debug` logs for warning messages.
12+
713
## Version 1.0.2 - 15.07.2024
814

915
### Changed

lib/compile/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const getChannels = require('./channels');
55
const cds = require('@sap/cds/lib');
66
const { join } = require('path');
77
const messages = require("./message");
8+
const DEBUG = cds.debug('cds:asyncapi');
89
const presetMapping = {
910
'event_spec_version': 'x-sap-event-spec-version',
1011
'event_source': 'x-sap-event-source',
@@ -29,7 +30,7 @@ module.exports = function processor(csn, options = {}) {
2930
const ordNamespace = _getNamespace(cds.env.ord.namespace);
3031
const asyncapiNamespace = _getNamespace(envConf.application_namespace);
3132
if (ordNamespace !== asyncapiNamespace) {
32-
console.warn(messages.NAMESPACE_MISMATCH)
33+
DEBUG?.(messages.NAMESPACE_MISMATCH)
3334
}
3435
}
3536

test/lib/compile/asyncapiMetadata.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,12 @@ describe('asyncapi export: presets and annotations', () => {
9494
const generatedAsyncAPI = toAsyncAPI(csn);
9595
expect(generatedAsyncAPI).toHaveProperty('x-sap-application-namespace','customer.cap-js-asyncapi')
9696
});
97+
test('Console warnings and errors are not used', async () => {
98+
const inputCDS = await read(join(baseInputPath, 'valid', 'presets.cds'));
99+
const csn = cds.compile.to.csn(inputCDS);
100+
const generatedAsyncAPI = toAsyncAPI(csn);
101+
102+
expect(generatedAsyncAPI).not.toHaveProperty('console.warn');
103+
expect(generatedAsyncAPI).not.toHaveProperty('console.error');
104+
});
97105
});

0 commit comments

Comments
 (0)