@@ -4,55 +4,42 @@ import _ from 'lodash'
44
55import chalkExt from './chalkExt'
66
7+ // TODO: use static props -> update babel!
78class Logger {
89
9- // use static props -> update babel!
1010 defaults = {
11- prefix : '[StackR23]' ,
12- debug : { color : 'cyan' , prefix : 'DEBUG' } ,
13- error : { color : 'red' , prefix : 'ERROR' } ,
14- success : { color : 'green' , prefix : 'SUCCESS' }
11+ prefix : '{bold.yellow [StackR23] }' ,
12+ log : { style : 'reset' , prefix : 'bold.yellow LOG - ' } ,
13+ debug : { style : 'cyan' , prefix : '{bold.cyan DEBUG: }' } ,
14+ error : { style : 'red' , prefix : '{bold.red ERROR: }' } ,
15+ success : { style : 'green' , prefix : '{bold.green SUCCESS: }' }
1516 }
1617
1718 constructor ( options ) {
18- console . log ( 'options :>> ' , options )
19-
2019 this . options = _ . merge ( this . defaults , options )
2120 console . log ( 'this.defaults :>> ' , this . defaults )
2221 console . log ( 'this.options :>> ' , this . options )
2322 }
2423
25- log ( str , typePrefix , styleType , styleString ) {
26- if ( arguments . length === 1 ) {
27- console . log ( chalkExt `{${ this . options . prefixColor } .bold ${ this . options . prefix } } ${ str } ` )
28-
29- return true
30- }
31-
32- if ( arguments . length === 2 ) {
33- const type = typePrefix
34- const { color, prefix} = this . options [ type ] //
24+ log ( str , type = 'log' , styleCustom ) {
25+ const { prefix, [ type ] : typeOptions } = this . options
3526
36- typePrefix = prefix || type
37- // styleType = colorType || color
38- styleString = color
27+ if ( arguments . length === 1 ) {
28+ console . log ( chalkExt ` ${ prefix } ${ str } ` )
29+ return
3930 }
4031
4132 console . log (
42- // ${styleType}
43- chalkExt `{{bold ${ this . options . prefix } ${ typePrefix } :} {${ styleString } ${ str } }`
33+ ( prefix ? chalkExt `${ prefix } ` : '' ) +
34+ ( typeOptions . prefix ? chalkExt `${ typeOptions . prefix } ` : '' ) +
35+ chalkExt `{${ typeOptions . style } ${ str } }`
4436 )
45-
46- return true
4737 }
4838
49- dir = arg => console . dir ( ...arg )
50-
5139 debug = str => this . log ( str , 'debug' )
52-
53- error = str => this . log ( str , 'error' ) //, `${this.options.errorColor}Bright.bgBlack`, this.options.errorColor)
54-
55- success = str => this . log ( str , 'success' ) //, `${this.options.successColor}Bright`, this.options.successColor)
40+ error = str => this . log ( str , 'error' )
41+ success = str => this . log ( str , 'success' )
5642}
5743
44+ export { Logger }
5845export default new Logger ( )
0 commit comments