isomorphic-rslog
Advanced tools
Comparing version 0.0.0-1729783623737 to 0.0.1
@@ -43,3 +43,3 @@ declare let LOG_TYPES: { | ||
type LogLevel = 'error' | 'warn' | 'info' | 'log' | 'verbose'; | ||
type ColorFn = (input: string | number | null | undefined) => string[]; | ||
type ColorFn = (input: string | number | null | undefined | [label: string, style: string]) => string[]; | ||
type LogMessage = unknown; | ||
@@ -52,4 +52,8 @@ interface LogType { | ||
type LogFunction = (message?: LogMessage, ...args: any[]) => void; | ||
type Labels = { | ||
[key in LogMethods]?: string; | ||
}; | ||
interface Options { | ||
level?: LogLevel; | ||
labels?: Labels; | ||
} | ||
@@ -56,0 +60,0 @@ type LogMethods = keyof typeof LOG_TYPES; |
{ | ||
"name": "isomorphic-rslog", | ||
"version": "0.0.0-1729783623737", | ||
"version": "0.0.1", | ||
"types": "./dist/index.d.ts", | ||
"author": "hanric <hanric.zhang@gmail.com>", | ||
"browser": "./dist/browser/index.cjs", | ||
@@ -17,3 +18,5 @@ "main": "./dist/node/index.cjs", | ||
"reset": "rimraf ./**/node_modules", | ||
"test": "vitest" | ||
"test": "npm run test:node && npm run test:browser", | ||
"test:node": "vitest -c vitest.node.config.ts", | ||
"test:browser": "vitest -c vitest.browser.config.ts" | ||
}, | ||
@@ -23,6 +26,5 @@ "engines": { | ||
}, | ||
"packageManager": "pnpm@8.8.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/rspack-contrib/rslog.git" | ||
"url": "https://github.com/2heal1/isomorphic-rslog.git" | ||
}, | ||
@@ -33,2 +35,3 @@ "devDependencies": { | ||
"@types/node": "~16.11.7", | ||
"jsdom": "^25.0.1", | ||
"prettier": "~2.8.1", | ||
@@ -38,3 +41,3 @@ "rimraf": "~3.0.2", | ||
"typescript": "~5.0.4", | ||
"vitest": "^2.0.5" | ||
"vitest": "2.0.5" | ||
}, | ||
@@ -41,0 +44,0 @@ "publishConfig": { |
@@ -1,4 +0,4 @@ | ||
# Rslog | ||
# isomorphic-rslog | ||
A tiny, intuitive, type-friendly logger for Node.js. | ||
A tiny, intuitive, type-friendly logger for Node.js/Browser. | ||
@@ -18,12 +18,12 @@ - **Tiny**. [2kB gzipped](https://bundlephobia.com/package/rslog@1). | ||
# with npm | ||
npm add rslog | ||
npm add isomorphic-rslog | ||
# with yarn | ||
yarn add rslog | ||
yarn add isomorphic-rslog | ||
# with pnpm | ||
pnpm add rslog | ||
pnpm add isomorphic-rslog | ||
# with bun | ||
bun add rslog | ||
bun add isomorphic-rslog | ||
``` | ||
@@ -37,6 +37,6 @@ | ||
// with require | ||
const { logger } = require('rslog'); | ||
const { logger } = require('isomorphic-rslog'); | ||
// with import | ||
import { logger } from 'rslog'; | ||
import { logger } from 'isomorphic-rslog'; | ||
``` | ||
@@ -81,3 +81,3 @@ | ||
```js | ||
import { createLogger } from 'rslog'; | ||
import { createLogger } from 'isomorphic-rslog'; | ||
@@ -111,2 +111,31 @@ const logger = createLogger({ level: 'warn' }); | ||
## Label Prefix | ||
You can create a new logger instance through `createLogger` and specify the label prefix: | ||
```js | ||
import { createLogger } from 'isomorphic-rslog'; | ||
const logger = createLogger({ level: 'warn' }); | ||
const logger = createLogger({ | ||
labels:{ | ||
warn:'[ Prefix ] Warn', | ||
error:'[ Prefix ] Error', | ||
success:'[ Prefix ] Success', | ||
info:'[ Prefix ] Info', | ||
log:'[ Prefix ] Log', | ||
ready:'[ Prefix ] Ready', | ||
debug:'[ Prefix ] Debug', | ||
} | ||
}); | ||
logger.log('this is a log message'); | ||
logger.info('this is an info message'); | ||
logger.warn('this is a warn message'); | ||
logger.ready('this is a ready message'); | ||
logger.debug('this is a debug message'); | ||
logger.success('this is a success message'); | ||
``` | ||
## Override | ||
@@ -117,3 +146,3 @@ | ||
```js | ||
import { logger } from 'rslog'; | ||
import { logger } from 'isomorphic-rslog'; | ||
@@ -138,12 +167,14 @@ logger.override({ | ||
Rslog provides both CommonJS and ESModule output and supports Node.js >= 14. | ||
`isomorphic-rslog` provides both CommonJS and ESModule output and supports Node.js >= 14. | ||
## Credits | ||
Rslog is built with [Modern.js](https://github.com/web-infra-dev/modern.js). | ||
`isomorphic-rslog` is fork from [rslog](https://github.com/rspack-contrib/rslog). | ||
The color implementation of Rslog are modified from [alexeyraspopov/picocolors](https://github.com/alexeyraspopov/picocolors). | ||
`isomorphic-rslog` is built with [Modern.js](https://github.com/web-infra-dev/modern.js). | ||
The color implementation of `isomorphic-rslog` are modified from [alexeyraspopov/picocolors](https://github.com/alexeyraspopov/picocolors). | ||
## License | ||
Rslog is [MIT licensed](https://github.com/rspack-contrib/rslog/blob/main/LICENSE). | ||
`isomorphic-rslog` is [MIT licensed](https://github.com/rspack-contrib/rslog/blob/main/LICENSE). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
25432
668
1
175
9