Skip to content

Commit e044b2e

Browse files
committed
Merge branch 'develop'
2 parents 90b10cd + f8605dc commit e044b2e

File tree

3 files changed

+37
-53
lines changed

3 files changed

+37
-53
lines changed

package.json

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,16 @@
8383
},
8484
"homepage": "https://github.com/stackr23/logger#readme",
8585
"devDependencies": {
86-
"@babel/cli": "^7.1.5",
87-
"@babel/core": "^7.1.6",
88-
"@babel/plugin-proposal-class-properties": "^7.1.0",
89-
"@babel/preset-env": "^7.1.6",
90-
"@babel/register": "^7.0.0",
86+
"@babel/cli": "^7.13.16",
87+
"@babel/core": "^7.14.0",
88+
"@babel/plugin-proposal-class-properties": "^7.13.0",
89+
"@babel/preset-env": "^7.14.1",
90+
"@babel/register": "^7.13.16",
9191
"@viewar/config-eslint": "^1.12.0",
92-
"babel-eslint": "^10.0.1",
93-
"babel-preset-minify": "^0.5.0",
94-
"eslint": "^6.0.0",
95-
"eslint-config-airbnb": "^17.1.0",
96-
"eslint-plugin-import": "^2.17.0",
97-
"eslint-plugin-jsx-a11y": "^6.1.2",
98-
"eslint-plugin-node": "^9.0.0",
99-
"eslint-plugin-promise": "^4.0.1",
100-
"eslint-plugin-react": "^7.12.3",
101-
"eslint-plugin-standard": "^4.0.0",
92+
"babel-preset-minify": "^0.5.1",
10293
"husky": "^6.0.0",
10394
"lint-staged": "^10.5.4",
104-
"lodash": "^4.17.21",
105-
"travis-deploy-once": "^5.0.9"
95+
"lodash": "^4.17.21"
10696
},
10797
"dependencies": {
10898
"chalk": "^4.1.1"

src/index.js

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,42 @@ import _ from 'lodash'
44

55
import chalkExt from './chalkExt'
66

7+
// TODO: use static props -> update babel!
78
class 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}
5845
export default new Logger()

test/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
/* eslint-disable-next-line import/no-unresolved */
2-
import Logger from '../src'
1+
import {Logger} from '../src/index'
32

4-
Logger.success('logger running!')
5-
Logger.error('unexpected bahavior')
6-
// Logger.log('{reset.magenta custom {bgBlackBright.yellow output style}}')
7-
Logger.debug('standard debug info')
3+
const log = new Logger({
4+
prefix: '{cyan.bold [CUSTOM PREFIX] }',
5+
debug: {prefix: '{bold.blue CUSTOMDEBUG }'}
6+
})
7+
8+
log.debug('standard debug message')
9+
log.debug('{bgBlue.magenta CUSTOM{reset.yellow debug}{bgBlack.cyan info}}')
10+
11+
log.error('unexpected bahavior')
12+
log.success('logger running!')
13+
14+
log.log('{bgBlue.bold.magenta custom output style}')
815

0 commit comments

Comments
 (0)