@blocklet/logger 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +19 -0
  2. package/lib/index.js +8 -0
  3. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Blocklet logger
2
+
3
+ A library to facilitate Blocklet logging.
4
+
5
+ ## Usage
6
+
7
+ ```javascript
8
+ const logger = require('@blocklet/logger');
9
+
10
+ // log
11
+ log = logger('demo');
12
+ log.info('this is demo', { id: 'test-id' });
13
+ log.warn('this is demo', { id: 'test-id' });
14
+ log.error('this is demo', { id: 'test-id' });
15
+ log.debug('this is demo', { id: 'test-id' });
16
+
17
+ // access log
18
+ app.use(morgan('combined', { stream: logger.getAccessLogStream() }));
19
+ ```
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ const logger = require('@abtnode/logger');
2
+
3
+ if (!process.env.BLOCKLET_LOG_DIR) {
4
+ throw new Error('valid BLOCKLET_LOG_DIR env is required by logger');
5
+ }
6
+
7
+ module.exports = (label) => logger(label, { logDir: process.env.BLOCKLET_LOG_DIR, filename: 'info' });
8
+ module.exports.getAccessLogStream = () => logger.getAccessLogStream(process.env.BLOCKLET_LOG_DIR);
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@blocklet/logger",
3
+ "version": "1.8.2",
4
+ "description": "A library to facilitate Blocklet logging",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "keywords": [
9
+ "blocklet"
10
+ ],
11
+ "author": "polunzh <polunzh@gmail.com>",
12
+ "homepage": "",
13
+ "license": "MIT",
14
+ "main": "lib/index.js",
15
+ "directories": {
16
+ "lib": "lib",
17
+ "test": "tests"
18
+ },
19
+ "files": [
20
+ "lib"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/ArcBlock"
25
+ },
26
+ "scripts": {
27
+ "lint": "eslint tests lib",
28
+ "lint:fix": "eslint --fix tests lib",
29
+ "test": "node tools/jest.js",
30
+ "coverage": "npm run test -- --coverage"
31
+ },
32
+ "dependencies": {
33
+ "@abtnode/logger": "1.8.2"
34
+ },
35
+ "devDependencies": {
36
+ "jest": "^27.4.5"
37
+ },
38
+ "gitHead": "fcbe3c97f3825c507ee16714f49bbf8f58c5b59f"
39
+ }