@stacksjs/logging 0.59.7 → 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.d.ts +0 -1
- package/dist/index.js +10 -5
- package/package.json +1 -1
- package/src/index.ts +13 -5
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { Prompt } from '@stacksjs/cli';
|
|
|
3
3
|
export declare function logLevel(): any;
|
|
4
4
|
export declare const logger: import("consola/core").ConsolaInstance;
|
|
5
5
|
export { consola };
|
|
6
|
-
export declare const logFilePath: string;
|
|
7
6
|
export interface Log {
|
|
8
7
|
info: (...args: any[]) => void;
|
|
9
8
|
success: (msg: string) => void;
|
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
|
-
|
|
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
|
}
|
|
@@ -1819,7 +1826,6 @@ function echo(...args) {
|
|
|
1819
1826
|
var logger = createConsola2({
|
|
1820
1827
|
level: logLevel()
|
|
1821
1828
|
});
|
|
1822
|
-
var logFilePath = logsPath("console.log");
|
|
1823
1829
|
var log = {
|
|
1824
1830
|
async info(...arg) {
|
|
1825
1831
|
logger.info(...arg);
|
|
@@ -1863,7 +1869,6 @@ var log = {
|
|
|
1863
1869
|
export {
|
|
1864
1870
|
logger,
|
|
1865
1871
|
logLevel,
|
|
1866
|
-
logFilePath,
|
|
1867
1872
|
log,
|
|
1868
1873
|
echo,
|
|
1869
1874
|
dump,
|
package/package.json
CHANGED
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
|
/**
|
|
@@ -41,12 +42,19 @@ export const logger = createConsola({
|
|
|
41
42
|
|
|
42
43
|
export { consola }
|
|
43
44
|
|
|
44
|
-
export const logFilePath = logsPath('console.log')
|
|
45
|
-
|
|
46
45
|
async function writeToLogFile(message: string) {
|
|
47
46
|
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`
|
|
48
47
|
try {
|
|
49
|
-
|
|
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
|
+
}
|
|
50
58
|
}
|
|
51
59
|
catch (error) {
|
|
52
60
|
console.error('Failed to write to log file:', error)
|