@witchcraft/nuxt-logger 0.0.9 → 0.0.10

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/dist/module.d.mts CHANGED
@@ -68,6 +68,8 @@ interface ModuleOptions {
68
68
  })[];
69
69
  /** Disable a transport target by it's target name. */
70
70
  disabledServerTransportTargets?: string[];
71
+ /** Whether to ensure the log dirs exist (for disabling when using the module in layers) */
72
+ ensureLogDirs?: boolean;
71
73
  }
72
74
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
73
75
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "logger",
3
3
  "configKey": "logger",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -23,7 +23,8 @@ const module = defineNuxtModule({
23
23
  ],
24
24
  enableServerRequestLogging: false,
25
25
  additionalServerTransportTargets: [],
26
- disabledServerTransportTargets: []
26
+ disabledServerTransportTargets: [],
27
+ ensureLogDirs: true
27
28
  },
28
29
  async setup(options, nuxt) {
29
30
  const { resolve } = createResolver(import.meta.url);
@@ -31,17 +32,19 @@ const module = defineNuxtModule({
31
32
  const maybeAppName = nuxt.options.runtimeConfig.public?.appInfo?.name;
32
33
  const appName = options.appName ?? maybeAppName ?? path.basename(await resolvePath("~~", { alias: nuxt.options.alias }));
33
34
  options.serverLogPath ??= path.relative(nuxt.options.rootDir, resolveAlias(`~~/logs/${appName}.log`, nuxt.options.alias));
34
- if (process.env.NODE_ENV === "development") {
35
- if (!await fs.stat(options.devServerLogPath).then(() => true).catch(() => false)) {
36
- await fs.mkdir(path.dirname(options.devServerLogPath), {
37
- recursive: true
38
- });
39
- await fs.writeFile(options.devServerLogPath, "");
40
- }
41
- } else {
42
- if (!await fs.stat(options.serverLogPath).then(() => true).catch(() => false)) {
43
- await fs.mkdir(path.dirname(options.serverLogPath), { recursive: true });
44
- await fs.writeFile(options.serverLogPath, "");
35
+ if (options.ensureLogDirs) {
36
+ if (process.env.NODE_ENV === "development") {
37
+ if (!await fs.stat(options.devServerLogPath).then(() => true).catch(() => false)) {
38
+ await fs.mkdir(path.dirname(options.devServerLogPath), {
39
+ recursive: true
40
+ });
41
+ await fs.writeFile(options.devServerLogPath, "");
42
+ }
43
+ } else {
44
+ if (!await fs.stat(options.serverLogPath).then(() => true).catch(() => false)) {
45
+ await fs.mkdir(path.dirname(options.serverLogPath), { recursive: true });
46
+ await fs.writeFile(options.serverLogPath, "");
47
+ }
45
48
  }
46
49
  }
47
50
  nuxt.options.runtimeConfig.public.logger = defu(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@witchcraft/nuxt-logger",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Nuxt module for logging.",
5
5
  "repository": "witchcraftjs/nuxt-logger",
6
6
  "license": "MIT",
package/src/module.ts CHANGED
@@ -81,6 +81,8 @@ export interface ModuleOptions {
81
81
  })[]
82
82
  /** Disable a transport target by it's target name. */
83
83
  disabledServerTransportTargets?: string[]
84
+ /** Whether to ensure the log dirs exist (for disabling when using the module in layers) */
85
+ ensureLogDirs?: boolean
84
86
  }
85
87
 
86
88
  export default defineNuxtModule<ModuleOptions>({
@@ -103,7 +105,8 @@ export default defineNuxtModule<ModuleOptions>({
103
105
  ] as string[],
104
106
  enableServerRequestLogging: false,
105
107
  additionalServerTransportTargets: [],
106
- disabledServerTransportTargets: []
108
+ disabledServerTransportTargets: [],
109
+ ensureLogDirs: true
107
110
  },
108
111
  async setup(options, nuxt) {
109
112
  const { resolve } = createResolver(import.meta.url)
@@ -111,17 +114,19 @@ export default defineNuxtModule<ModuleOptions>({
111
114
  const maybeAppName = (nuxt.options.runtimeConfig.public as any)?.appInfo?.name
112
115
  const appName = options.appName ?? maybeAppName ?? path.basename(await resolvePath("~~", { alias: nuxt.options.alias }))
113
116
  options.serverLogPath ??= path.relative(nuxt.options.rootDir, resolveAlias(`~~/logs/${appName}.log`, nuxt.options.alias))
114
- if (process.env.NODE_ENV === "development") {
115
- if (!await fs.stat(options.devServerLogPath).then(() => true).catch(() => false)) {
116
- await fs.mkdir(path.dirname(options.devServerLogPath), {
117
- recursive: true
118
- })
119
- await fs.writeFile(options.devServerLogPath, "")
120
- }
121
- } else {
122
- if (!await fs.stat(options.serverLogPath).then(() => true).catch(() => false)) {
123
- await fs.mkdir(path.dirname(options.serverLogPath), { recursive: true })
124
- await fs.writeFile(options.serverLogPath, "")
117
+ if (options.ensureLogDirs) {
118
+ if (process.env.NODE_ENV === "development") {
119
+ if (!await fs.stat(options.devServerLogPath).then(() => true).catch(() => false)) {
120
+ await fs.mkdir(path.dirname(options.devServerLogPath), {
121
+ recursive: true
122
+ })
123
+ await fs.writeFile(options.devServerLogPath, "")
124
+ }
125
+ } else {
126
+ if (!await fs.stat(options.serverLogPath).then(() => true).catch(() => false)) {
127
+ await fs.mkdir(path.dirname(options.serverLogPath), { recursive: true })
128
+ await fs.writeFile(options.serverLogPath, "")
129
+ }
125
130
  }
126
131
  }
127
132