Skip to content

Commit

Permalink
docs: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
baozouai committed Feb 22, 2024
1 parent d5e3567 commit 958dbe4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
31 changes: 28 additions & 3 deletions README-zh_CN.md
Expand Up @@ -53,6 +53,14 @@ npm i vite-plugin-enhance-log -D

```ts
interface Options {
/** 高亮文件名(firefox不支持) */
colorFileName?: boolean
/**
* 匹配自定义log方法,默认是 /console\.log/
* @example
* logMethodReg: /console\.(log|error|warn|info|debug)/
*/
logMethodReg?: RegExp
/**
* 打印文件名
* 如果你文件名太长,希望不显示文件path的目录,比如src/pages/xxx/yyy/a.tsx, 那么可以配置enableDir为false,则只打印a.tsx
Expand All @@ -61,13 +69,30 @@ interface Options {
*/
enableFileName?: boolean | {
enableDir?: boolean
/**
* 自定义文件名
* @example
* filename: /Users/xxx/code/your-project/packages/main/src/index.ts
* root: /Users/xxx/code/your-project/packages/main
* rootSplitExp: /(.*?)packages
* the log will be main/src/index.ts
*/
custom?: (filename: string) => string
}
/**
* 打印的前缀提示,这样方便快速找到log 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
* 打印的前缀提示,这样方便快速找到log
* @example
* console.log(' 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀', ...)
* console.log
* ('🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀', ...)
* preTip: (logMethod) => {
* if (logMethod === 'console.error') return '❌❌❌❌❌'
* if (logMethod === 'console.warn') return '🚨🚨🚨🚨🚨'
* if (logMethod === 'console.info') return '💡💡💡💡💡'
* if (logMethod === 'console.debug') return '🐞🐞🐞🐞🐞'
* return '🚀🚀🚀🚀🚀'
* }
*/
preTip?: string
preTip?: string | ((logMethod: string) => string)
/** 每个参数分隔符,默认空字符串,你也可以使用换行符\n,分号;逗号,甚至猪猪🐖都行~ */
splitBy?: boolean
/**
Expand Down
28 changes: 26 additions & 2 deletions README.md
Expand Up @@ -55,6 +55,14 @@ npm i vite-plugin-enhance-log -D

```ts
interface Options {
/** colorful filename,but The firefox can't recognize color labels, and garbled characters appear */
colorFileName?: boolean
/**
* match log method reg, default /console\.log/, you can custom
* @example
* logMethodReg: /console\.(log|error|warn|info|debug)/
*/
logMethodReg?: RegExp
/**
* log file name
* If your file name is too long,
Expand All @@ -65,13 +73,29 @@ interface Options {
*/
enableFileName?: boolean | {
enableDir?: boolean
/**
* @example
* filename: /Users/xxx/code/your-project/packages/main/src/index.ts
* root: /Users/xxx/code/your-project/packages/main
* rootSplitExp: /(.*?)packages
* the log will be main/src/index.ts
*/
custom?: (filename: string) => string
}
/**
* tip of start argument default 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
* also, you can custom preTip by logMethod
* @example
* console.log(' 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀', ...)
* console.log('🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀', ...)
* preTip: (logMethod) => {
* if (logMethod === 'console.error') return '❌❌❌❌❌'
* if (logMethod === 'console.warn') return '🚨🚨🚨🚨🚨'
* if (logMethod === 'console.info') return '💡💡💡💡💡'
* if (logMethod === 'console.debug') return '🐞🐞🐞🐞🐞'
* return '🚀🚀🚀🚀🚀'
* }
*/
preTip?: string
preTip?: string | ((logMethod: string) => string)
/** the delimiter for each parameter is an empty string by default, you can also use a newline \n, a semicolon';' a comma',' or even a pig '🐖' */
splitBy?: boolean
/**
Expand Down
8 changes: 1 addition & 7 deletions src/index.ts
Expand Up @@ -45,14 +45,8 @@ export interface Options {
* logMethodReg: /console\.(log|error|warn|info|debug)/
*/
logMethodReg?: RegExp
// /**
// * tip of start argument default 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
// * @example
// * console.log('line of 1 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀', ...)
// */
// preTip?: string
/**
* to log filename, default false
* to log filename, default true
*/
enableFileName?: EnableFileName
/**
Expand Down

0 comments on commit 958dbe4

Please sign in to comment.