/**
 * 日志
 */ import fs from 'fs' ; export default class Log { private static logs : string [ ] = [ ] ; constructor ( ) { } static write ( ... str ) { const now = new Date ( ) ; const hour = now . getHours ( ) ; const minutes = now . getMinutes ( ) ; const second = now . getSeconds ( ) ; console . log ( `[ ${ hour }:${ minutes }:${ second } ]` , ... str ) ; this . logs . push ( `[ ${ hour }:${ minutes }:${ second } ] ` + str . join ( ' ' ) ) ; fs . writeFile ( './logs.data' , this . logs . join ( '\n' ) , ( err ) => { if ( err ) console . log ( '日志写入失败' ) ; } ) ; } }