@lowdefy/server-dev 0.0.0-experimental-20260126225618 → 0.0.0-experimental-20260202141107
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/lib/server/log/createLogger.js +53 -2
- package/lib/server/log/logError.js +15 -49
- package/manager/utils/createLogger.mjs +11 -0
- package/manager/utils/createStdOutLineHandler.mjs +17 -5
- package/manager/utils/getLowdefyVersion.mjs +8 -6
- package/package.json +28 -28
- package/package.original.json +28 -28
- package/pages/api/client-error.js +3 -10
|
@@ -16,14 +16,65 @@
|
|
|
16
16
|
|
|
17
17
|
import pino from 'pino';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
function formatReceived(message, received) {
|
|
20
|
+
if (received === undefined) {
|
|
21
|
+
return message;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return `${message} Received: ${JSON.stringify(received)}`;
|
|
25
|
+
} catch {
|
|
26
|
+
return `${message} Received: [unserializable]`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const pinoLogger = pino({
|
|
20
31
|
name: 'lowdefy_server',
|
|
21
32
|
level: process.env.LOWDEFY_LOG_LEVEL ?? 'info',
|
|
22
33
|
base: { pid: undefined, hostname: undefined },
|
|
34
|
+
serializers: {
|
|
35
|
+
err: (err) => ({
|
|
36
|
+
message: err.message,
|
|
37
|
+
name: err.name,
|
|
38
|
+
stack: err.stack,
|
|
39
|
+
source: err.source,
|
|
40
|
+
config: err.config,
|
|
41
|
+
configKey: err.configKey,
|
|
42
|
+
isServiceError: err.isServiceError,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
23
45
|
});
|
|
24
46
|
|
|
47
|
+
// Wrap logger to handle error objects passed to logger.error(error)
|
|
48
|
+
function wrapLogger(logger) {
|
|
49
|
+
const originalError = logger.error.bind(logger);
|
|
50
|
+
const originalInfo = logger.info.bind(logger);
|
|
51
|
+
|
|
52
|
+
logger.error = (errorOrMessage, ...args) => {
|
|
53
|
+
// If it's an Error object (has name property - covers Error instances and error-like objects)
|
|
54
|
+
if (errorOrMessage?.name) {
|
|
55
|
+
// Log source first if available
|
|
56
|
+
if (errorOrMessage.source) {
|
|
57
|
+
originalInfo(errorOrMessage.source);
|
|
58
|
+
}
|
|
59
|
+
const errorName = errorOrMessage.name || 'Error';
|
|
60
|
+
// Handle undefined message (which JS converts to string "undefined")
|
|
61
|
+
const rawMessage = errorOrMessage.message;
|
|
62
|
+
const message =
|
|
63
|
+
rawMessage && rawMessage !== 'undefined' ? rawMessage : 'Unknown error';
|
|
64
|
+
const errorMessage = formatReceived(message, errorOrMessage.received);
|
|
65
|
+
originalError(`[${errorName}] ${errorMessage}`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Pass through normal calls
|
|
69
|
+
originalError(errorOrMessage, ...args);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return logger;
|
|
73
|
+
}
|
|
74
|
+
|
|
25
75
|
function createLogger(metadata = {}) {
|
|
26
|
-
|
|
76
|
+
const childLogger = pinoLogger.child(metadata);
|
|
77
|
+
return wrapLogger(childLogger);
|
|
27
78
|
}
|
|
28
79
|
|
|
29
80
|
export default createLogger;
|
|
@@ -14,65 +14,31 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { resolveErrorConfigLocation } from '@lowdefy/errors/build';
|
|
18
18
|
|
|
19
19
|
import captureSentryError from '../sentry/captureSentryError.js';
|
|
20
20
|
|
|
21
|
-
async function resolveErrorConfigLocation(context, error) {
|
|
22
|
-
if (!error.configKey) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const [keyMap, refMap] = await Promise.all([
|
|
27
|
-
context.readConfigFile('keyMap.json'),
|
|
28
|
-
context.readConfigFile('refMap.json'),
|
|
29
|
-
]);
|
|
30
|
-
const location = resolveConfigLocation({
|
|
31
|
-
configKey: error.configKey,
|
|
32
|
-
keyMap,
|
|
33
|
-
refMap,
|
|
34
|
-
configDirectory: context.configDirectory,
|
|
35
|
-
});
|
|
36
|
-
return location || null;
|
|
37
|
-
} catch {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
21
|
async function logError({ context, error }) {
|
|
43
22
|
try {
|
|
44
|
-
const message = error?.message || 'Unknown error';
|
|
45
23
|
const isServiceError = error?.isServiceError === true;
|
|
46
24
|
|
|
47
25
|
// For service errors, don't resolve config location (not a config issue)
|
|
48
|
-
const location = isServiceError
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
26
|
+
const location = isServiceError
|
|
27
|
+
? null
|
|
28
|
+
: await resolveErrorConfigLocation({
|
|
29
|
+
error,
|
|
30
|
+
readConfigFile: context.readConfigFile,
|
|
31
|
+
configDirectory: context.configDirectory,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Attach resolved location to error for display layer
|
|
35
|
+
if (location) {
|
|
36
|
+
error.source = location.source;
|
|
37
|
+
error.config = location.config;
|
|
59
38
|
}
|
|
60
39
|
|
|
61
|
-
//
|
|
62
|
-
context.logger.error(
|
|
63
|
-
{
|
|
64
|
-
event: isServiceError ? 'service_error' : 'config_error',
|
|
65
|
-
errorName: error?.name || 'Error',
|
|
66
|
-
errorMessage: message,
|
|
67
|
-
isServiceError,
|
|
68
|
-
pageId: context.pageId || null,
|
|
69
|
-
timestamp: new Date().toISOString(),
|
|
70
|
-
source: location?.source || null,
|
|
71
|
-
config: location?.config || null,
|
|
72
|
-
link: location?.link || null,
|
|
73
|
-
},
|
|
74
|
-
message
|
|
75
|
-
);
|
|
40
|
+
// Log error - logger handles source, name prefix, and received formatting
|
|
41
|
+
context.logger.error(error);
|
|
76
42
|
|
|
77
43
|
// Capture error to Sentry (no-op if Sentry not configured)
|
|
78
44
|
captureSentryError({
|
|
@@ -26,6 +26,17 @@ function createLogger({ level = 'info' }) {
|
|
|
26
26
|
print: context.print ?? logger.levels.labels[level],
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
|
+
serializers: {
|
|
30
|
+
err: (err) => ({
|
|
31
|
+
message: err.message,
|
|
32
|
+
name: err.name,
|
|
33
|
+
stack: err.stack,
|
|
34
|
+
source: err.source,
|
|
35
|
+
config: err.config,
|
|
36
|
+
configKey: err.configKey,
|
|
37
|
+
isServiceError: err.isServiceError,
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
29
40
|
});
|
|
30
41
|
return logger;
|
|
31
42
|
}
|
|
@@ -18,13 +18,25 @@ function createStdOutLineHandler({ context }) {
|
|
|
18
18
|
const { logger } = context;
|
|
19
19
|
function stdOutLineHandler(line) {
|
|
20
20
|
try {
|
|
21
|
-
const { level,
|
|
22
|
-
if (level)
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const { level, msg, source, err } = JSON.parse(line);
|
|
22
|
+
if (!level) return;
|
|
23
|
+
|
|
24
|
+
const levelLabel = logger.levels.labels[level];
|
|
25
|
+
|
|
26
|
+
// Extract source from err (pino error serialization) or top-level (merging object)
|
|
27
|
+
const resolvedSource = err?.source ?? source;
|
|
28
|
+
|
|
29
|
+
// Error/warn with source: show source line (info/blue) before the message
|
|
30
|
+
if (resolvedSource && level >= 40) {
|
|
31
|
+
logger.info({ print: 'info' }, resolvedSource);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (msg) {
|
|
35
|
+
const print = level === 30 ? 'info' : levelLabel;
|
|
36
|
+
logger[levelLabel]({ print }, msg);
|
|
25
37
|
}
|
|
26
38
|
} catch (error) {
|
|
27
|
-
logger.info({ print: '
|
|
39
|
+
logger.info({ print: 'info' }, line);
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
return stdOutLineHandler;
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import { type } from '@lowdefy/helpers';
|
|
19
|
-
import {
|
|
19
|
+
import { readFile } from '@lowdefy/node-utils';
|
|
20
|
+
import { ConfigError } from '@lowdefy/errors/build';
|
|
20
21
|
import YAML from 'yaml';
|
|
21
22
|
|
|
22
23
|
async function getLowdefyVersion(context) {
|
|
@@ -44,11 +45,12 @@ async function getLowdefyVersion(context) {
|
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
if (!type.isString(lowdefy.lowdefy)) {
|
|
47
|
-
throw new
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
throw new ConfigError({
|
|
49
|
+
message: 'Version number specified in "lowdefy.yaml" file should be a string.',
|
|
50
|
+
received: lowdefy.lowdefy,
|
|
51
|
+
filePath,
|
|
52
|
+
configDirectory: context.directories.config,
|
|
53
|
+
});
|
|
52
54
|
}
|
|
53
55
|
return lowdefy.lowdefy;
|
|
54
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server-dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-20260202141107",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -36,33 +36,33 @@
|
|
|
36
36
|
".npmrc"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lowdefy/actions-core": "0.0.0-experimental-
|
|
40
|
-
"@lowdefy/api": "0.0.0-experimental-
|
|
41
|
-
"@lowdefy/block-utils": "0.0.0-experimental-
|
|
42
|
-
"@lowdefy/blocks-aggrid": "0.0.0-experimental-
|
|
43
|
-
"@lowdefy/blocks-antd": "0.0.0-experimental-
|
|
44
|
-
"@lowdefy/blocks-basic": "0.0.0-experimental-
|
|
45
|
-
"@lowdefy/blocks-color-selectors": "0.0.0-experimental-
|
|
46
|
-
"@lowdefy/blocks-echarts": "0.0.0-experimental-
|
|
47
|
-
"@lowdefy/blocks-loaders": "0.0.0-experimental-
|
|
48
|
-
"@lowdefy/blocks-markdown": "0.0.0-experimental-
|
|
49
|
-
"@lowdefy/blocks-qr": "0.0.0-experimental-
|
|
50
|
-
"@lowdefy/build": "0.0.0-experimental-
|
|
51
|
-
"@lowdefy/client": "0.0.0-experimental-
|
|
52
|
-
"@lowdefy/connection-axios-http": "0.0.0-experimental-
|
|
53
|
-
"@lowdefy/engine": "0.0.0-experimental-
|
|
54
|
-
"@lowdefy/helpers": "0.0.0-experimental-
|
|
55
|
-
"@lowdefy/layout": "0.0.0-experimental-
|
|
56
|
-
"@lowdefy/node-utils": "0.0.0-experimental-
|
|
57
|
-
"@lowdefy/operators-change-case": "0.0.0-experimental-
|
|
58
|
-
"@lowdefy/operators-diff": "0.0.0-experimental-
|
|
59
|
-
"@lowdefy/operators-js": "0.0.0-experimental-
|
|
60
|
-
"@lowdefy/operators-moment": "0.0.0-experimental-
|
|
61
|
-
"@lowdefy/operators-mql": "0.0.0-experimental-
|
|
62
|
-
"@lowdefy/operators-nunjucks": "0.0.0-experimental-
|
|
63
|
-
"@lowdefy/operators-uuid": "0.0.0-experimental-
|
|
64
|
-
"@lowdefy/operators-yaml": "0.0.0-experimental-
|
|
65
|
-
"@lowdefy/plugin-next-auth": "0.0.0-experimental-
|
|
39
|
+
"@lowdefy/actions-core": "0.0.0-experimental-20260202141107",
|
|
40
|
+
"@lowdefy/api": "0.0.0-experimental-20260202141107",
|
|
41
|
+
"@lowdefy/block-utils": "0.0.0-experimental-20260202141107",
|
|
42
|
+
"@lowdefy/blocks-aggrid": "0.0.0-experimental-20260202141107",
|
|
43
|
+
"@lowdefy/blocks-antd": "0.0.0-experimental-20260202141107",
|
|
44
|
+
"@lowdefy/blocks-basic": "0.0.0-experimental-20260202141107",
|
|
45
|
+
"@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260202141107",
|
|
46
|
+
"@lowdefy/blocks-echarts": "0.0.0-experimental-20260202141107",
|
|
47
|
+
"@lowdefy/blocks-loaders": "0.0.0-experimental-20260202141107",
|
|
48
|
+
"@lowdefy/blocks-markdown": "0.0.0-experimental-20260202141107",
|
|
49
|
+
"@lowdefy/blocks-qr": "0.0.0-experimental-20260202141107",
|
|
50
|
+
"@lowdefy/build": "0.0.0-experimental-20260202141107",
|
|
51
|
+
"@lowdefy/client": "0.0.0-experimental-20260202141107",
|
|
52
|
+
"@lowdefy/connection-axios-http": "0.0.0-experimental-20260202141107",
|
|
53
|
+
"@lowdefy/engine": "0.0.0-experimental-20260202141107",
|
|
54
|
+
"@lowdefy/helpers": "0.0.0-experimental-20260202141107",
|
|
55
|
+
"@lowdefy/layout": "0.0.0-experimental-20260202141107",
|
|
56
|
+
"@lowdefy/node-utils": "0.0.0-experimental-20260202141107",
|
|
57
|
+
"@lowdefy/operators-change-case": "0.0.0-experimental-20260202141107",
|
|
58
|
+
"@lowdefy/operators-diff": "0.0.0-experimental-20260202141107",
|
|
59
|
+
"@lowdefy/operators-js": "0.0.0-experimental-20260202141107",
|
|
60
|
+
"@lowdefy/operators-moment": "0.0.0-experimental-20260202141107",
|
|
61
|
+
"@lowdefy/operators-mql": "0.0.0-experimental-20260202141107",
|
|
62
|
+
"@lowdefy/operators-nunjucks": "0.0.0-experimental-20260202141107",
|
|
63
|
+
"@lowdefy/operators-uuid": "0.0.0-experimental-20260202141107",
|
|
64
|
+
"@lowdefy/operators-yaml": "0.0.0-experimental-20260202141107",
|
|
65
|
+
"@lowdefy/plugin-next-auth": "0.0.0-experimental-20260202141107",
|
|
66
66
|
"@sentry/nextjs": "8.53.0",
|
|
67
67
|
"chokidar": "3.5.3",
|
|
68
68
|
"dotenv": "16.3.1",
|
package/package.original.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server-dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-20260202141107",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -43,33 +43,33 @@
|
|
|
43
43
|
"prepublishOnly": "pnpm build"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lowdefy/actions-core": "0.0.0-experimental-
|
|
47
|
-
"@lowdefy/api": "0.0.0-experimental-
|
|
48
|
-
"@lowdefy/block-utils": "0.0.0-experimental-
|
|
49
|
-
"@lowdefy/blocks-aggrid": "0.0.0-experimental-
|
|
50
|
-
"@lowdefy/blocks-antd": "0.0.0-experimental-
|
|
51
|
-
"@lowdefy/blocks-basic": "0.0.0-experimental-
|
|
52
|
-
"@lowdefy/blocks-color-selectors": "0.0.0-experimental-
|
|
53
|
-
"@lowdefy/blocks-echarts": "0.0.0-experimental-
|
|
54
|
-
"@lowdefy/blocks-loaders": "0.0.0-experimental-
|
|
55
|
-
"@lowdefy/blocks-markdown": "0.0.0-experimental-
|
|
56
|
-
"@lowdefy/blocks-qr": "0.0.0-experimental-
|
|
57
|
-
"@lowdefy/build": "0.0.0-experimental-
|
|
58
|
-
"@lowdefy/client": "0.0.0-experimental-
|
|
59
|
-
"@lowdefy/connection-axios-http": "0.0.0-experimental-
|
|
60
|
-
"@lowdefy/engine": "0.0.0-experimental-
|
|
61
|
-
"@lowdefy/helpers": "0.0.0-experimental-
|
|
62
|
-
"@lowdefy/layout": "0.0.0-experimental-
|
|
63
|
-
"@lowdefy/node-utils": "0.0.0-experimental-
|
|
64
|
-
"@lowdefy/operators-change-case": "0.0.0-experimental-
|
|
65
|
-
"@lowdefy/operators-diff": "0.0.0-experimental-
|
|
66
|
-
"@lowdefy/operators-js": "0.0.0-experimental-
|
|
67
|
-
"@lowdefy/operators-moment": "0.0.0-experimental-
|
|
68
|
-
"@lowdefy/operators-mql": "0.0.0-experimental-
|
|
69
|
-
"@lowdefy/operators-nunjucks": "0.0.0-experimental-
|
|
70
|
-
"@lowdefy/operators-uuid": "0.0.0-experimental-
|
|
71
|
-
"@lowdefy/operators-yaml": "0.0.0-experimental-
|
|
72
|
-
"@lowdefy/plugin-next-auth": "0.0.0-experimental-
|
|
46
|
+
"@lowdefy/actions-core": "0.0.0-experimental-20260202141107",
|
|
47
|
+
"@lowdefy/api": "0.0.0-experimental-20260202141107",
|
|
48
|
+
"@lowdefy/block-utils": "0.0.0-experimental-20260202141107",
|
|
49
|
+
"@lowdefy/blocks-aggrid": "0.0.0-experimental-20260202141107",
|
|
50
|
+
"@lowdefy/blocks-antd": "0.0.0-experimental-20260202141107",
|
|
51
|
+
"@lowdefy/blocks-basic": "0.0.0-experimental-20260202141107",
|
|
52
|
+
"@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260202141107",
|
|
53
|
+
"@lowdefy/blocks-echarts": "0.0.0-experimental-20260202141107",
|
|
54
|
+
"@lowdefy/blocks-loaders": "0.0.0-experimental-20260202141107",
|
|
55
|
+
"@lowdefy/blocks-markdown": "0.0.0-experimental-20260202141107",
|
|
56
|
+
"@lowdefy/blocks-qr": "0.0.0-experimental-20260202141107",
|
|
57
|
+
"@lowdefy/build": "0.0.0-experimental-20260202141107",
|
|
58
|
+
"@lowdefy/client": "0.0.0-experimental-20260202141107",
|
|
59
|
+
"@lowdefy/connection-axios-http": "0.0.0-experimental-20260202141107",
|
|
60
|
+
"@lowdefy/engine": "0.0.0-experimental-20260202141107",
|
|
61
|
+
"@lowdefy/helpers": "0.0.0-experimental-20260202141107",
|
|
62
|
+
"@lowdefy/layout": "0.0.0-experimental-20260202141107",
|
|
63
|
+
"@lowdefy/node-utils": "0.0.0-experimental-20260202141107",
|
|
64
|
+
"@lowdefy/operators-change-case": "0.0.0-experimental-20260202141107",
|
|
65
|
+
"@lowdefy/operators-diff": "0.0.0-experimental-20260202141107",
|
|
66
|
+
"@lowdefy/operators-js": "0.0.0-experimental-20260202141107",
|
|
67
|
+
"@lowdefy/operators-moment": "0.0.0-experimental-20260202141107",
|
|
68
|
+
"@lowdefy/operators-mql": "0.0.0-experimental-20260202141107",
|
|
69
|
+
"@lowdefy/operators-nunjucks": "0.0.0-experimental-20260202141107",
|
|
70
|
+
"@lowdefy/operators-uuid": "0.0.0-experimental-20260202141107",
|
|
71
|
+
"@lowdefy/operators-yaml": "0.0.0-experimental-20260202141107",
|
|
72
|
+
"@lowdefy/plugin-next-auth": "0.0.0-experimental-20260202141107",
|
|
73
73
|
"@sentry/nextjs": "8.53.0",
|
|
74
74
|
"chokidar": "3.5.3",
|
|
75
75
|
"dotenv": "16.3.1",
|
|
@@ -23,19 +23,12 @@ async function handler({ context, req, res }) {
|
|
|
23
23
|
if (req.method !== 'POST') {
|
|
24
24
|
throw new Error('Only POST requests are supported.');
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
const response = await logClientError(context, {
|
|
28
|
-
configKey,
|
|
29
|
-
message,
|
|
30
|
-
name,
|
|
31
|
-
pageId,
|
|
32
|
-
timestamp,
|
|
33
|
-
});
|
|
26
|
+
const response = await logClientError(context, req.body);
|
|
34
27
|
|
|
35
28
|
// Capture client error to Sentry (no-op if Sentry not configured)
|
|
36
29
|
captureSentryError({
|
|
37
|
-
error: new Error(message),
|
|
38
|
-
context
|
|
30
|
+
error: new Error(req.body.message),
|
|
31
|
+
context,
|
|
39
32
|
configLocation: response.source
|
|
40
33
|
? { source: response.source, config: response.config, link: response.link }
|
|
41
34
|
: null,
|