@witchcraft/nuxt-logger 0.0.2 → 0.0.3
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
CHANGED
|
@@ -46,7 +46,7 @@ Also redacts the `redact` key, but only in production, so you can put anything s
|
|
|
46
46
|
The electron logger requires a bit of setup since electron's main cannot be passed the runtime config normally.
|
|
47
47
|
|
|
48
48
|
This assumes the usage of
|
|
49
|
-
[@witchcraft/nuxt-electron](
|
|
49
|
+
[@witchcraft/nuxt-electron](https://github.com/witchcraftjs/nuxt-electron) since it can handle this among other issues.
|
|
50
50
|
|
|
51
51
|
There is a full example in the [@witchcraft/nuxt-electron playground](TODO).
|
|
52
52
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, resolvePath, addImportsDir, addServerImportsDir, addServerHandler, addPlugin } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, resolveAlias, resolvePath, addImportsDir, addServerImportsDir, addServerHandler, addPlugin } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
@@ -27,10 +27,10 @@ const module = defineNuxtModule({
|
|
|
27
27
|
},
|
|
28
28
|
async setup(options, nuxt) {
|
|
29
29
|
const { resolve } = createResolver(import.meta.url);
|
|
30
|
-
options.devServerLogPath ??=
|
|
30
|
+
options.devServerLogPath ??= path.relative(nuxt.options.rootDir, resolveAlias("~~/logs/server.log", nuxt.options.alias));
|
|
31
31
|
const maybeAppName = nuxt.options.runtimeConfig.public?.appInfo?.name;
|
|
32
32
|
const appName = options.appName ?? maybeAppName ?? path.basename(await resolvePath("~~", { alias: nuxt.options.alias }));
|
|
33
|
-
options.serverLogPath ??=
|
|
33
|
+
options.serverLogPath ??= path.relative(nuxt.options.rootDir, resolveAlias(`~~/logs/${appName}.log`, nuxt.options.alias));
|
|
34
34
|
if (process.env.NODE_ENV === "development") {
|
|
35
35
|
if (!await fs.stat(options.devServerLogPath).then(() => true).catch(() => false)) {
|
|
36
36
|
await fs.mkdir(path.dirname(options.devServerLogPath), {
|
|
@@ -3,6 +3,7 @@ import { keys } from "@alanscodelog/utils/keys";
|
|
|
3
3
|
import { readable } from "@alanscodelog/utils/readable";
|
|
4
4
|
import { set } from "@alanscodelog/utils/set";
|
|
5
5
|
import { walk } from "@alanscodelog/utils/walk";
|
|
6
|
+
import path from "node:path";
|
|
6
7
|
import { pino } from "pino";
|
|
7
8
|
const levels = {
|
|
8
9
|
values: {
|
|
@@ -67,6 +68,7 @@ export function getBaseOptions(config) {
|
|
|
67
68
|
return {
|
|
68
69
|
debug: {
|
|
69
70
|
logPath,
|
|
71
|
+
resolvedLogPath: path.resolve(logPath),
|
|
70
72
|
writeLevel,
|
|
71
73
|
logLevel
|
|
72
74
|
},
|
|
@@ -77,6 +79,7 @@ export function getBaseOptions(config) {
|
|
|
77
79
|
formatters: {
|
|
78
80
|
bindings: () => ({})
|
|
79
81
|
},
|
|
82
|
+
// @ts-expect-error https://github.com/pinojs/pino/issues/2260
|
|
80
83
|
timestamp: pino.stdTimeFunctions.isoTime
|
|
81
84
|
},
|
|
82
85
|
browserOpts: {
|
|
@@ -99,7 +102,7 @@ export function getBaseOptions(config) {
|
|
|
99
102
|
level: writeLevel,
|
|
100
103
|
target: "pino/file",
|
|
101
104
|
options: {
|
|
102
|
-
destination: logPath,
|
|
105
|
+
destination: path.resolve(logPath),
|
|
103
106
|
mkdir: true
|
|
104
107
|
}
|
|
105
108
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witchcraft/nuxt-logger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Nuxt module for logging.",
|
|
5
5
|
"repository": "witchcraftjs/nuxt-logger",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"pino-pretty": "^11.2.2"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@alanscodelog/tsconfigs": "^6.
|
|
44
|
+
"@alanscodelog/tsconfigs": "^6.2.0",
|
|
45
45
|
"@alanscodelog/utils": "^6.0.1",
|
|
46
46
|
"@nuxt/kit": "^4.0.3",
|
|
47
47
|
"defu": "latest",
|
package/src/module.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
addServerImportsDir,
|
|
6
6
|
createResolver,
|
|
7
7
|
defineNuxtModule,
|
|
8
|
+
resolveAlias,
|
|
8
9
|
resolvePath
|
|
9
10
|
} from "@nuxt/kit"
|
|
10
11
|
import { defu } from "defu"
|
|
@@ -106,10 +107,10 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
106
107
|
},
|
|
107
108
|
async setup(options, nuxt) {
|
|
108
109
|
const { resolve } = createResolver(import.meta.url)
|
|
109
|
-
options.devServerLogPath ??=
|
|
110
|
+
options.devServerLogPath ??= path.relative(nuxt.options.rootDir, resolveAlias("~~/logs/server.log", nuxt.options.alias))
|
|
110
111
|
const maybeAppName = (nuxt.options.runtimeConfig.public as any)?.appInfo?.name
|
|
111
112
|
const appName = options.appName ?? maybeAppName ?? path.basename(await resolvePath("~~", { alias: nuxt.options.alias }))
|
|
112
|
-
options.serverLogPath ??=
|
|
113
|
+
options.serverLogPath ??= path.relative(nuxt.options.rootDir, resolveAlias(`~~/logs/${appName}.log`, nuxt.options.alias))
|
|
113
114
|
if (process.env.NODE_ENV === "development") {
|
|
114
115
|
if (!await fs.stat(options.devServerLogPath).then(() => true).catch(() => false)) {
|
|
115
116
|
await fs.mkdir(path.dirname(options.devServerLogPath), {
|
|
@@ -4,6 +4,7 @@ import { readable } from "@alanscodelog/utils/readable"
|
|
|
4
4
|
import { set } from "@alanscodelog/utils/set"
|
|
5
5
|
import { walk } from "@alanscodelog/utils/walk"
|
|
6
6
|
import type { PublicRuntimeConfig } from "@nuxt/schema"
|
|
7
|
+
import path from "node:path"
|
|
7
8
|
import type { LoggerOptions, TransportMultiOptions } from "pino"
|
|
8
9
|
import { pino } from "pino"
|
|
9
10
|
|
|
@@ -38,6 +39,7 @@ export function getBaseOptions(
|
|
|
38
39
|
transports: TransportMultiOptions
|
|
39
40
|
debug: {
|
|
40
41
|
logPath: string
|
|
42
|
+
resolvedLogPath: string
|
|
41
43
|
writeLevel: string
|
|
42
44
|
logLevel: string
|
|
43
45
|
}
|
|
@@ -103,6 +105,7 @@ export function getBaseOptions(
|
|
|
103
105
|
return {
|
|
104
106
|
debug: {
|
|
105
107
|
logPath,
|
|
108
|
+
resolvedLogPath: path.resolve(logPath),
|
|
106
109
|
writeLevel,
|
|
107
110
|
logLevel
|
|
108
111
|
},
|
|
@@ -113,6 +116,7 @@ export function getBaseOptions(
|
|
|
113
116
|
formatters: {
|
|
114
117
|
bindings: () => ({})
|
|
115
118
|
},
|
|
119
|
+
// @ts-expect-error https://github.com/pinojs/pino/issues/2260
|
|
116
120
|
timestamp: pino.stdTimeFunctions.isoTime
|
|
117
121
|
},
|
|
118
122
|
browserOpts: {
|
|
@@ -137,7 +141,7 @@ export function getBaseOptions(
|
|
|
137
141
|
level: writeLevel,
|
|
138
142
|
target: "pino/file",
|
|
139
143
|
options: {
|
|
140
|
-
destination: logPath,
|
|
144
|
+
destination: path.resolve(logPath),
|
|
141
145
|
mkdir: true
|
|
142
146
|
}
|
|
143
147
|
},
|