lazylog-trace 1.0.0 → 1.0.1
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.
- package/README.md +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# lazylog-trace
|
|
2
2
|
|
|
3
3
|
Request-scoped logging for Express. All logs produced during a request are tied to that request and stored (SQLite by default). Retrieve logs by request id, and optionally attach context (e.g. user id) to every log for that request.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ No UI, no heavy abstractions—just middleware, a request-scoped logger, and per
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install lazylog
|
|
10
|
+
npm install lazylog-trace-trace
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Peer dependency: **Express** (v4 or v5). You must have `express` installed in your app.
|
|
@@ -25,23 +25,23 @@ npm test
|
|
|
25
25
|
|
|
26
26
|
This runs the integration test (Express app, one request, asserts logs and request are stored). You need Node.js build tools for the `better-sqlite3` native addon; on Windows you may need [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) or Visual Studio Build Tools.
|
|
27
27
|
|
|
28
|
-
**Test lazylog in another repo (local development):**
|
|
28
|
+
**Test lazylog-trace in another repo (local development):**
|
|
29
29
|
|
|
30
|
-
1. In **lazylog** (this repo):
|
|
30
|
+
1. In **lazylog-trace** (this repo):
|
|
31
31
|
`npm link`
|
|
32
32
|
|
|
33
33
|
2. In your **app repo**:
|
|
34
|
-
`npm link lazylog`
|
|
35
|
-
Then use it as usual: `const { requestLogger, getRequestLogger } = require('lazylog');`
|
|
34
|
+
`npm link lazylog-trace`
|
|
35
|
+
Then use it as usual: `const { requestLogger, getRequestLogger } = require('lazylog-trace');`
|
|
36
36
|
|
|
37
37
|
**Or install from a tarball (no link):**
|
|
38
38
|
|
|
39
|
-
1. In **lazylog**:
|
|
39
|
+
1. In **lazylog-trace**:
|
|
40
40
|
`npm pack`
|
|
41
|
-
This creates `lazylog-1.0.0.tgz`.
|
|
41
|
+
This creates `lazylog-trace-1.0.0.tgz`.
|
|
42
42
|
|
|
43
43
|
2. In your **app repo**:
|
|
44
|
-
`npm install /path/to/lazylog/lazylog-1.0.0.tgz`
|
|
44
|
+
`npm install /path/to/lazylog-trace/lazylog-trace-1.0.0.tgz`
|
|
45
45
|
|
|
46
46
|
## Usage
|
|
47
47
|
|
|
@@ -50,7 +50,7 @@ This runs the integration test (Express app, one request, asserts logs and reque
|
|
|
50
50
|
Mount the middleware to enable request-scoped logging and persistence:
|
|
51
51
|
|
|
52
52
|
```js
|
|
53
|
-
const { requestLogger } = require('lazylog');
|
|
53
|
+
const { requestLogger } = require('lazylog-trace');
|
|
54
54
|
|
|
55
55
|
app.use(express.json()); // if you need req.body
|
|
56
56
|
app.use(requestLogger({
|
|
@@ -77,7 +77,7 @@ app.use(requestLogger({
|
|
|
77
77
|
Inside any route or downstream middleware, get the logger for the current request:
|
|
78
78
|
|
|
79
79
|
```js
|
|
80
|
-
const { getRequestLogger } = require('lazylog');
|
|
80
|
+
const { getRequestLogger } = require('lazylog-trace');
|
|
81
81
|
|
|
82
82
|
app.post('/login', (req, res) => {
|
|
83
83
|
const log = getRequestLogger();
|
|
@@ -111,7 +111,7 @@ log.info('User action'); // stored with userId and email in context
|
|
|
111
111
|
Use the stored data in your app or a simple admin route:
|
|
112
112
|
|
|
113
113
|
```js
|
|
114
|
-
const { getLogsByRequestId, getRequest } = require('lazylog');
|
|
114
|
+
const { getLogsByRequestId, getRequest } = require('lazylog-trace');
|
|
115
115
|
|
|
116
116
|
// All log entries for a request
|
|
117
117
|
const logs = getLogsByRequestId(requestId);
|
|
@@ -143,7 +143,7 @@ Before publishing:
|
|
|
143
143
|
|
|
144
144
|
1. **Set repo URLs** in `package.json`: replace `YOUR_USERNAME` in `repository`, `bugs`, and `homepage` with your GitHub username (or org).
|
|
145
145
|
2. **Set author** in `package.json`, e.g. `"author": "Your Name <you@example.com>"` or `"author": "https://github.com/YOUR_USERNAME"`.
|
|
146
|
-
3. **Check the package name**: `lazylog` may be taken on npm. Use `npm search lazylog` or pick a scoped name, e.g. `@yourusername/lazylog`.
|
|
146
|
+
3. **Check the package name**: `lazylog-trace` may be taken on npm. Use `npm search lazylog-trace` or pick a scoped name, e.g. `@yourusername/lazylog-trace`.
|
|
147
147
|
4. **Log in**: `npm login`
|
|
148
148
|
5. **Dry run**: `npm publish --dry-run` to see what will be published (only `src/`, `README.md`, and `LICENSE` are included via the `files` field).
|
|
149
|
-
6. **Publish**: `npm publish` (or `npm publish --access public` if using a scoped package like `@yourusername/lazylog`).
|
|
149
|
+
6. **Publish**: `npm publish` (or `npm publish --access public` if using a scoped package like `@yourusername/lazylog-trace`).
|
package/package.json
CHANGED