fix(clamav.manager): Improve log handling and add timeout for log reception in ClamAV manager tests

This commit is contained in:
2025-02-03 13:55:15 +01:00
parent e31e7cca44
commit 4446f265cb
7 changed files with 175 additions and 29 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartantivirus',
version: '1.1.0',
version: '1.1.1',
description: 'A Node.js package for integrating antivirus scanning capabilities using ClamAV, allowing in-memory file and data scanning.'
}

View File

@ -11,11 +11,16 @@ export class ClamAVManager extends EventEmitter {
private containerName = 'clamav-daemon';
private imageTag = 'clamav/clamav:latest';
private port = 3310;
private logs: ClamAVLogEvent[] = [];
constructor() {
super();
}
public getLogs(): ClamAVLogEvent[] {
return this.logs;
}
/**
* Start the ClamAV container if it's not already running
*/
@ -157,6 +162,7 @@ export class ClamAVManager extends EventEmitter {
type: this.determineLogType(line)
};
this.logs.push(event);
this.emit('log', event);
console.log(`[ClamAV ${event.type}] ${event.message}`);
});
@ -169,6 +175,7 @@ export class ClamAVManager extends EventEmitter {
type: 'error'
};
this.logs.push(event);
this.emit('log', event);
console.error(`[ClamAV error] ${event.message}`);
});