loggerutil.js 670 B

1234567891011121314151617181920212223242526272829303132
  1. class LoggerUtil {
  2. constructor(prefix, style){
  3. this.prefix = prefix
  4. this.style = style
  5. }
  6. log(){
  7. console.log.apply(null, [this.prefix, this.style, ...arguments])
  8. }
  9. info(){
  10. console.info.apply(null, [this.prefix, this.style, ...arguments])
  11. }
  12. warn(){
  13. console.warn.apply(null, [this.prefix, this.style, ...arguments])
  14. }
  15. debug(){
  16. console.debug.apply(null, [this.prefix, this.style, ...arguments])
  17. }
  18. error(){
  19. console.error.apply(null, [this.prefix, this.style, ...arguments])
  20. }
  21. }
  22. module.exports = function (prefix, style){
  23. return new LoggerUtil(prefix, style)
  24. }