@stacksjs/logging 0.59.8 → 0.59.9

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/index.js CHANGED
@@ -1777,7 +1777,8 @@ var init_consola_36c0034f = __esm(() => {
1777
1777
 
1778
1778
  // src/index.ts
1779
1779
  import process2 from "process";
1780
- import {appendFile} from "fs/promises";
1780
+ import {appendFile, mkdir} from "fs/promises";
1781
+ import {dirname} from "path";
1781
1782
 
1782
1783
  // ../../../../node_modules/consola/dist/index.mjs
1783
1784
  init_consola_36c0034f();
@@ -1788,9 +1789,9 @@ init_utils();
1788
1789
  // src/index.ts
1789
1790
  import {ExitCode} from "@stacksjs/types";
1790
1791
  import {config as config2} from "@stacksjs/config";
1791
- import {logsPath} from "@stacksjs/path";
1792
1792
  import {handleError} from "@stacksjs/error-handling";
1793
1793
  import {buddyOptions, prompt as getPrompt} from "@stacksjs/cli";
1794
+ import {logsPath} from "@stacksjs/path";
1794
1795
  function logLevel() {
1795
1796
  const verboseRegex = /--verbose(?!(\s*=\s*false|\s+false))(\s+|=true)?($|\s)/;
1796
1797
  const opts = buddyOptions();
@@ -1801,7 +1802,13 @@ function logLevel() {
1801
1802
  async function writeToLogFile(message) {
1802
1803
  const formattedMessage = `[${new Date().toISOString()}] ${message}\n`;
1803
1804
  try {
1804
- await appendFile(logsPath("console.log"), formattedMessage);
1805
+ try {
1806
+ const logFilePath = logsPath("console.log");
1807
+ await mkdir(dirname(logFilePath), { recursive: true });
1808
+ await appendFile(logFilePath, formattedMessage);
1809
+ } catch (error) {
1810
+ console.error("Failed to write to log file:", error);
1811
+ }
1805
1812
  } catch (error) {
1806
1813
  console.error("Failed to write to log file:", error);
1807
1814
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/logging",
3
3
  "type": "module",
4
- "version": "0.59.8",
4
+ "version": "0.59.9",
5
5
  "description": "The Stacks logging system.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import process from 'node:process'
2
- import { appendFile } from 'node:fs/promises'
2
+ import { appendFile, mkdir } from 'node:fs/promises'
3
+ import { dirname } from 'node:path'
3
4
  import { consola, createConsola } from 'consola'
4
5
  import { ExitCode } from '@stacksjs/types'
5
6
  import { config } from '@stacksjs/config'
6
- import { logsPath } from '@stacksjs/path'
7
7
  import { handleError } from '@stacksjs/error-handling'
8
8
  import type { Prompt } from '@stacksjs/cli'
9
9
  import { buddyOptions, prompt as getPrompt } from '@stacksjs/cli'
10
+ import { logsPath } from '@stacksjs/path'
10
11
 
11
12
  export function logLevel() {
12
13
  /**
@@ -44,7 +45,16 @@ export { consola }
44
45
  async function writeToLogFile(message: string) {
45
46
  const formattedMessage = `[${new Date().toISOString()}] ${message}\n`
46
47
  try {
47
- await appendFile(logsPath('console.log'), formattedMessage)
48
+ try {
49
+ const logFilePath = logsPath('console.log')
50
+ // Ensure the directory exists
51
+ await mkdir(dirname(logFilePath), { recursive: true })
52
+ // Append the message to the log file
53
+ await appendFile(logFilePath, formattedMessage)
54
+ }
55
+ catch (error) {
56
+ console.error('Failed to write to log file:', error)
57
+ }
48
58
  }
49
59
  catch (error) {
50
60
  console.error('Failed to write to log file:', error)