import { Writable } from "stream" ; import IVSCServerManagerEventsHandler from "./IVSCServerManagerEventsHandler" ; import VSCServerManagerBase from "./VSCServerManagerBase" ; export default class VSCAccessLog implements IVSCServerManagerEventsHandler { public constructor ( private readonly logStream ) { } public onStart ( serverManager , session ) { this . logStream . write ( `${ serverManager . name } is starting...\n` ) ; } public onStartFail ( serverManager , session , error ) { this . logStream . write ( `${ serverManager . name } starts failed with error: ${ error . message } ${ error . stack }\n` ) ; } public onStartSuccess ( serverManager , session ) { const server = serverManager . getServer ( ) ! ; this . logStream . write ( `${ serverManager . name } successfully listens on ${ server . getHttpServerAddress ( ) }\n` ) ; } public onClean ( serverManager , session ) { this . logStream . write ( `${ serverManager . name } is cleaning.\n` ) ; } public onCleanFail ( serverManager , session , error ) { this . logStream . write ( `${ serverManager . name } failed to clean with error: ${ error . message } ${ error . stack }\n` ) ; } public onCleanSuccess ( serverManager , session ) { this . logStream . write ( `${ serverManager . name } successfully cleaned.\n` ) ; } public onClose ( serverManager , session ) { this . logStream . write ( `${ serverManager . name } is closing.\n` ) ; } public onCloseFail ( serverManager , session , error ) { this . logStream . write ( `${ serverManager . name } failed to close with error: ${ error . message } ${ error . stack }\n` ) ; } public onCloseSuccess ( serverManager , session ) { this . logStream . write ( `${ serverManager . name } successfully closed.\n` ) ; } }