Skip to content

Commit 5a592d9

Browse files
authored
fix: add default log filters for HikariDataSource and TableUtils (#34)
* fix: add default log filters for HikariDataSource and TableUtils After BanManager routes HikariCP/ORMLite output through the plugin logger instead of System.err, these messages become visible to WebEnhancer's log appender. Add default ignoreContains entries to filter out DB startup noise from report logs, and add E2E tests for the new filters. Related: BanManagement/BanManager#1050 * fix: add HikariDataSource and TableUtils filters to e2e platform configs The e2e config files are bind-mounted into Docker containers and since ignoreContains already exists, copyDefaults(true) won't append new entries from the JAR defaults. * fix: rename TableUtils test marker to avoid self-filtering NormalMarkerTableUtils_ contained the substring 'TableUtils' and was being filtered by the very ignoreContains rule under test.
1 parent d6a7821 commit 5a592d9

8 files changed

Lines changed: 64 additions & 0 deletions

File tree

common/src/main/resources/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ ignoreContains:
1414
- '[PlugMan]'
1515
- 'Metrics'
1616
- 'For help, type "help"'
17+
- 'HikariDataSource'
18+
- 'TableUtils'

e2e/platforms/bukkit/configs/banmanager-webenhancer/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ ignoreContains:
1414
- '[PlugMan]'
1515
- 'Metrics'
1616
- 'For help, type "help"'
17+
- 'HikariDataSource'
18+
- 'TableUtils'
1719

e2e/platforms/bungee/configs/banmanager-webenhancer/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ ignoreContains:
1212
- '[PlugMan]'
1313
- Metrics
1414
- For help, type "help"
15+
- 'HikariDataSource'
16+
- 'TableUtils'

e2e/platforms/fabric/configs/banmanager-webenhancer/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ ignoreContains:
1414
- '[PlugMan]'
1515
- 'Metrics'
1616
- 'For help, type "help"'
17+
- 'HikariDataSource'
18+
- 'TableUtils'
1719

e2e/platforms/sponge/configs/banmanager-webenhancer/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ ignoreContains:
1414
- '[PlugMan]'
1515
- 'Metrics'
1616
- 'For help, type "help"'
17+
- 'HikariDataSource'
18+
- 'TableUtils'
1719

e2e/platforms/sponge7/configs/banmanager-webenhancer/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ ignoreContains:
1414
- '[PlugMan]'
1515
- 'Metrics'
1616
- 'For help, type "help"'
17+
- 'HikariDataSource'
18+
- 'TableUtils'
1719

e2e/platforms/velocity/configs/banmanager-webenhancer/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ ignoreContains:
1414
- '[PlugMan]'
1515
- 'Metrics'
1616
- 'For help, type "help"'
17+
- 'HikariDataSource'
18+
- 'TableUtils'

e2e/tests/src/log-filtering.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,54 @@ describeOrSkip('Log Filtering (ignoreContains)', () => {
231231
console.log('Report command output correctly filtered')
232232
}
233233
}, 60000)
234+
235+
test('HikariDataSource messages are filtered from report logs', async () => {
236+
const uniqueId = Date.now()
237+
const hikariMessage = `HikariDataSource pool starting_${uniqueId}`
238+
const normalMessage = `NormalMarkerHikari_${uniqueId}`
239+
const logs = await captureLogsForReason(
240+
'Testing HikariDataSource filter',
241+
normalMessage,
242+
async () => {
243+
await sendCommand(`say ${hikariMessage}`)
244+
await sendCommand(`say ${normalMessage}`)
245+
}
246+
)
247+
248+
expect(logs).not.toBeNull()
249+
if (logs != null) {
250+
const hikariFound = logs.some(log => log.message.includes(hikariMessage))
251+
expect(hikariFound).toBe(false)
252+
253+
const normalFound = logs.some(log => log.message.includes(normalMessage))
254+
expect(normalFound).toBe(true)
255+
256+
console.log('HikariDataSource messages correctly filtered')
257+
}
258+
}, 60000)
259+
260+
test('TableUtils messages are filtered from report logs', async () => {
261+
const uniqueId = Date.now()
262+
const tableUtilsMessage = `TableUtils creating table_${uniqueId}`
263+
const normalMessage = `NormalMarkerTblUtils_${uniqueId}`
264+
const logs = await captureLogsForReason(
265+
'Testing TableUtils filter',
266+
normalMessage,
267+
async () => {
268+
await sendCommand(`say ${tableUtilsMessage}`)
269+
await sendCommand(`say ${normalMessage}`)
270+
}
271+
)
272+
273+
expect(logs).not.toBeNull()
274+
if (logs != null) {
275+
const tableUtilsFound = logs.some(log => log.message.includes(tableUtilsMessage))
276+
expect(tableUtilsFound).toBe(false)
277+
278+
const normalFound = logs.some(log => log.message.includes(normalMessage))
279+
expect(normalFound).toBe(true)
280+
281+
console.log('TableUtils messages correctly filtered')
282+
}
283+
}, 60000)
234284
})

0 commit comments

Comments
 (0)