11'use strict' ;
22
3- const chalk = require ( 'chalk' ) . default ;
3+ const chalk = require ( 'chalk' ) ;
44const utils = require ( 'util' ) ;
55const ora = require ( 'ora' ) ;
6+ const os = require ( 'os' ) ;
67
78const getStdoutMethod = function ( type ) {
89 if ( ! process ) {
@@ -20,30 +21,30 @@ const getStdoutMethod = function(type) {
2021const toString = {
2122 debug ( ) {
2223 const message = utils . format ( ...( arguments || [ ] ) ) ;
23- return `${ chalk . bgMagenta ( ' DEBUG ' ) } ${ message } \r\n ` ;
24+ return `${ chalk . bgMagenta ( ' DEBUG ' ) } ${ message } ${ os . EOL } ` ;
2425 } ,
2526 warn ( ) {
2627 const message = utils . format ( ...( arguments || [ ] ) ) ;
27- return `${ chalk . bgYellowBright . black ( ' WARN ' ) } ${ chalk . yellowBright ( message ) } \r\n ` ;
28+ return `${ chalk . bgYellowBright . black ( ' WARN ' ) } ${ chalk . yellowBright ( message ) } ${ os . EOL } ` ;
2829 } ,
2930 error ( ) {
3031 const message = utils . format ( ...( arguments || [ ] ) ) ;
31- return `${ chalk . bgRed ( ' ERROR ' ) } ${ chalk . redBright ( message ) } \r\n ` ;
32+ return `${ chalk . bgRed ( ' ERROR ' ) } ${ chalk . redBright ( message ) } ${ os . EOL } ` ;
3233 } ,
3334 info ( ) {
3435 const message = utils . format ( ...( arguments || [ ] ) ) ;
35- return `${ chalk . bgBlue ( ' INFO ' ) } ${ chalk . blueBright ( message ) } \r\n ` ;
36+ return `${ chalk . bgBlue ( ' INFO ' ) } ${ chalk . blueBright ( message ) } ${ os . EOL } ` ;
3637 } ,
3738 success ( ) {
3839 const message = utils . format ( ...( arguments || [ ] ) ) ;
39- return `${ chalk . bgHex ( '#007007' ) ( ' SUCCESS ' ) } ${ chalk . greenBright ( message ) } \r\n ` ;
40+ return `${ chalk . bgHex ( '#007007' ) ( ' SUCCESS ' ) } ${ chalk . greenBright ( message ) } ${ os . EOL } ` ;
4041 } ,
4142} ;
4243
4344module . exports = {
4445 toString,
4546 debug ( ) {
46- if ( ! process . env . MICRO_DEBUG_LOGGER ) return ; // 是否开启
47+ if ( ! process . env . MICRO_APP_DEBUG_LOGGER ) return ; // 是否开启
4748 return getStdoutMethod ( 'log' ) ( toString . debug . call ( toString , ...arguments ) ) ;
4849 } ,
4950 warn ( ) {
@@ -79,12 +80,12 @@ module.exports = {
7980 const error = e ;
8081 this . error ( ...Array . prototype . splice . call ( arguments , 1 ) ) ;
8182 const stack = error . stack . split ( / \r ? \n / mg) ;
82- getStdoutMethod ( 'error' ) ( chalk . grey ( stack . slice ( 1 ) . join ( '\r\n' ) ) + '\r\n' ) ;
83+ getStdoutMethod ( 'error' ) ( chalk . grey ( stack . slice ( 1 ) . join ( os . EOL ) ) + os . EOL ) ;
8384 } else {
8485 const error = new Error ( ) ;
8586 this . error ( ...arguments ) ;
8687 const stack = error . stack . split ( / \r ? \n / mg) ;
87- getStdoutMethod ( 'error' ) ( chalk . grey ( stack . slice ( 2 ) . join ( '\r\n' ) ) + '\r\n' ) ;
88+ getStdoutMethod ( 'error' ) ( chalk . grey ( stack . slice ( 2 ) . join ( os . EOL ) ) + os . EOL ) ;
8889 }
8990 process . exit ( 1 ) ;
9091 } ,
0 commit comments