@opengis/fastify-table 2.0.71 → 2.0.72

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.
@@ -30,7 +30,7 @@ export default function transportTarget() {
30
30
  source.on("data", (obj) => {
31
31
  if (["incoming request", "request completed"].includes(obj.msg))
32
32
  return;
33
- // console.log(obj)
33
+ // if (config.trace) console.log(obj, streams);
34
34
  const file = obj.msg?.logfolder || obj.logfolder;
35
35
  const level = file || labels[obj.level];
36
36
  const lvl = level + dt;
@@ -1 +1 @@
1
- {"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,UAAU,cAAe,SAAQ,IAAI,CAAC,MAAM;IAC1C,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;AAuCD,QAAA,MAAM,MAAM,EAAE,cAAgD,CAAC;AA4B/D,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,UAAU,cAAe,SAAQ,IAAI,CAAC,MAAM;IAC1C,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D;AAkDD,QAAA,MAAM,MAAM,EAAE,cAAgD,CAAC;AA4B/D,eAAe,MAAM,CAAC"}
@@ -8,24 +8,33 @@ import serializers from "./serializers.js";
8
8
  import timestampWithTimeZone from "./timestampWithTimeZone.js";
9
9
  const isServer = process.argv[2];
10
10
  const rclient2 = getRedis({ db: 2 });
11
- const level = config.log?.level || process.env.PINO_LOG_LEVEL || "info";
11
+ const level = process.env.LOG_LEVEL || "info";
12
12
  console.log(`log level: ${level}`);
13
+ const targets = [
14
+ {
15
+ target: "./createFileStream.js", // path.resolve('utils/createFileStream.js')
16
+ },
17
+ {
18
+ level: "error",
19
+ target: "pino/file",
20
+ options: { destination: 1 },
21
+ },
22
+ ];
23
+ // push trace logs to console (those would not be saved to file)
24
+ if (["trace", "debug"].includes(level)) {
25
+ targets.push({
26
+ level,
27
+ target: "pino/file",
28
+ options: { destination: 1 },
29
+ });
30
+ }
13
31
  const options = {
14
32
  level, // minimal log level to write
15
33
  timestamp: () => `,"time":"${timestampWithTimeZone()}"`, // timestamp as isostring
16
34
  hooks: getHooks(),
17
35
  serializers, // custom log params
18
36
  transport: {
19
- targets: [
20
- {
21
- target: "./createFileStream.js", // path.resolve('utils/createFileStream.js')
22
- },
23
- {
24
- level: "error",
25
- target: "pino/file",
26
- options: { destination: 1 },
27
- },
28
- ],
37
+ targets,
29
38
  },
30
39
  redact: redactionList,
31
40
  };
@@ -1,2 +1,3 @@
1
- export default function getRootDir(): any;
1
+ declare const _default: () => string;
2
+ export default _default;
2
3
  //# sourceMappingURL=getRootDir.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRootDir.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getRootDir.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,UAAU,QAqBjC"}
1
+ {"version":3,"file":"getRootDir.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/getRootDir.ts"],"names":[],"mappings":";AAIA,wBAA4B"}
@@ -1,22 +1,3 @@
1
- /* eslint-disable no-console */
2
- import fs from "node:fs";
3
1
  import path from "node:path";
4
- import config from "../../../config.js";
5
- let logDir = null;
6
- export default function getRootDir() {
7
- // absolute / relative path
8
- if (config.logDir) {
9
- console.log(`logging to: ${config.logDir}`);
10
- return config.logDir;
11
- }
12
- if (logDir) {
13
- console.log(`logging to: ${logDir}`);
14
- return logDir;
15
- }
16
- const file = ["config.json", "/data/local/config.json"].find((el) => fs.existsSync(el) ? el : null);
17
- // .env / config.json => process.cwd()
18
- const root = file && file.startsWith("/data/local") ? "/data/local" : process.cwd();
19
- logDir = path.join(root, config.log?.dir || "log");
20
- console.log(`logging to: ${logDir}`);
21
- return logDir;
22
- }
2
+ const logDir = process.env.LOG_DIR || path.join(process.cwd(), "log");
3
+ export default () => logDir;
@@ -1,4 +1,3 @@
1
- export default function testLog(request: any): Promise<{
2
- root: boolean;
3
- }>;
1
+ import { FastifyReply } from "fastify";
2
+ export default function testLog(request: any, reply: FastifyReply): Promise<never>;
4
3
  //# sourceMappingURL=logger.test.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.test.api.d.ts","sourceRoot":"","sources":["../../../../../server/routes/logger/controllers/logger.test.api.ts"],"names":[],"mappings":"AAGA,wBAA8B,OAAO,CAAC,OAAO,EAAE,GAAG;;GA4CjD"}
1
+ {"version":3,"file":"logger.test.api.d.ts","sourceRoot":"","sources":["../../../../../server/routes/logger/controllers/logger.test.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,wBAA8B,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA2BtE"}
@@ -1,42 +1,25 @@
1
- /* eslint-disable no-unreachable */
2
- import { rename } from 'fs/promises';
3
- export default async function testLog(request) {
4
- // error handler
1
+ import { rename } from "node:fs/promises";
2
+ import logger from "../../../plugins/logger/getLogger.js";
3
+ export default async function testLog(request, reply) {
4
+ logger.metrics("logger-test");
5
+ logger.file("logger-test", { code: 200, start: true });
5
6
  if (request.query?.rejection) {
6
- rename('/data/local/test', '/data/local/test.txt');
7
+ rename("/data/local/test", "/data/local/test.txt");
7
8
  }
8
9
  if (request.query?.awaitRejection) {
9
- await rename('/data/local/test', '/data/local/test.txt');
10
+ await rename("/data/local/test", "/data/local/test.txt");
10
11
  }
11
- // default pino log
12
- // request.log.info({ name: 'custom', test: 'param name and object log - info', status: 200 });
13
- /* request.log.info('string info log');
14
- //request.log.warn({ name: 'custom', test: 'param name and object log - warn', status: 400 });
15
- request.log.warn('string warn log');
16
- //request.log.debug({ name: 'custom', test: 'param name and object log - debug', status: 200 });
17
- request.log.debug('string debug log');
18
- //request.log.error({ name: 'custom', test: 'param name and object log - error', status: 200 });
19
- //request.log.error('string error log');
20
- request.log.fatal({ name: 'custom', test: 'param name and object log - fatal', status: 200 });
21
- //request.log.fatal('string fatal log'); */
22
- // custom params
23
- // request.log.info(request, { file: 'test', msg: 'string debug log' });
24
- // request.log.info({ file: 'test', msg: 'string debug log1' }, request);
25
- // request.log.file('test1', 'my message', request);
26
- throw new Error('444');
27
- request.log.info({ data: 111, msg: 'string debug log1' }, request);
28
- request.log.info('string debug log1', request);
29
- request.log.info('string debug log1');
30
- request.log.info({ data: 111, msg: 'string debug log1' });
31
- request.log.error(new Error('222'), request);
32
- /* request.log.error('policy and string log1');
33
- request.log.error({ test: 'policy and string log1' });
34
- request.log.error(request, { test: 'string name and object log', status: 502 });
35
- request.log.error(request, 'policy and string log1'); */
36
- // request.log.error(request, { test: 'policy and object error log', status: 500 });
37
- // request.log.error(request, 'policy and string log2');
38
- /// throw new Error('222');
39
- // d / 0;
40
- // throw new Error('unhandled exception');
41
- return { root: true };
12
+ if (request.query?.throw) {
13
+ throw new Error("444");
14
+ }
15
+ logger.trace({ data: 111, msg: "string trace log1" }, request);
16
+ logger.debug({ data: 111, msg: "string debug log1" }, request);
17
+ logger.warn({ data: 111, msg: "string warn log1" }, request);
18
+ logger.fatal({ data: 111, msg: "string fatal log1" }, request);
19
+ logger.info({ data: 111, msg: "string info log1" }, request);
20
+ logger.info("string info log1", request);
21
+ logger.info("string info log1");
22
+ logger.info({ data: 111, msg: "string info log1" });
23
+ logger.error(new Error("222"), request);
24
+ return reply.status(200).send({ root: true });
42
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.71",
3
+ "version": "2.0.72",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -31,7 +31,7 @@
31
31
  "compress": "node compress.js",
32
32
  "dev1": "bun --hot dist/server",
33
33
  "dev": "NODE_ENV=production bun start",
34
- "start": "bun server"
34
+ "start": "LOG_LEVEL=trace bun server"
35
35
  },
36
36
  "dependencies": {
37
37
  "@aws-sdk/client-s3": "3.879.0",