@@ -12,16 +12,25 @@ const getDateTimeString = (date: Date) => {
1212 return `${ day } /${ month } /${ year } ${ hours } :${ minutes } :${ seconds } ` ;
1313} ;
1414
15+ const defaultOptions : LogesticOptions = {
16+ showLevel : true
17+ } ;
18+
1519export default ( options : LogesticOptions ) =>
16- new Logestic ( options ) . use ( [ 'time' , 'method' , 'path' ] ) . format ( {
17- onSuccess ( { time, method, path } ) {
18- const dateTime = chalk . gray ( getDateTimeString ( time ! ! ) ) ;
19- const methodPath = chalk . cyan ( `${ method } ${ path } ` ) ;
20+ new Logestic ( {
21+ ...defaultOptions ,
22+ ...options
23+ } )
24+ . use ( [ 'time' , 'method' , 'path' ] )
25+ . format ( {
26+ onSuccess ( { time, method, path } ) {
27+ const dateTime = chalk . gray ( getDateTimeString ( time ! ! ) ) ;
28+ const methodPath = chalk . cyan ( `${ method } ${ path } ` ) ;
2029
21- return `${ dateTime } ${ methodPath } ` ;
22- } ,
23- onFailure ( { request, datetime } ) {
24- const dateTime = getDateTimeString ( datetime ! ! ) ;
25- return chalk . red ( `${ dateTime } ${ request . method } ${ request . url } ` ) ;
26- }
27- } ) ;
30+ return `${ dateTime } ${ methodPath } ` ;
31+ } ,
32+ onFailure ( { request, datetime } ) {
33+ const dateTime = getDateTimeString ( datetime ! ! ) ;
34+ return chalk . red ( `${ dateTime } ${ request . method } ${ request . url } ` ) ;
35+ }
36+ } ) ;
0 commit comments