@stacksjs/logging 0.59.2 → 0.59.4
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 +1 -1
- package/dist/index.js +3 -10
- package/package.json +2 -2
- package/src/index.ts +3 -12
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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:
|
|
6
|
+
export declare const logFilePath: string;
|
|
7
7
|
export interface Log {
|
|
8
8
|
info: (...args: any[]) => void;
|
|
9
9
|
success: (msg: string) => void;
|
package/dist/index.js
CHANGED
|
@@ -1777,6 +1777,7 @@ 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
1781
|
|
|
1781
1782
|
// ../../../../node_modules/consola/dist/index.mjs
|
|
1782
1783
|
init_consola_36c0034f();
|
|
@@ -1800,17 +1801,9 @@ function logLevel() {
|
|
|
1800
1801
|
async function writeToLogFile(message) {
|
|
1801
1802
|
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`;
|
|
1802
1803
|
try {
|
|
1803
|
-
|
|
1804
|
-
const writer = file.writer();
|
|
1805
|
-
const text2 = await file.text();
|
|
1806
|
-
writer.write(`${text2}\n`);
|
|
1807
|
-
writer.write(`${formattedMessage}\n`);
|
|
1808
|
-
await writer.end();
|
|
1804
|
+
await appendFile(logFilePath, formattedMessage);
|
|
1809
1805
|
} catch (error) {
|
|
1810
|
-
|
|
1811
|
-
const writer = file.writer();
|
|
1812
|
-
writer.write(`${formattedMessage}\n`);
|
|
1813
|
-
await writer.end();
|
|
1806
|
+
console.error("Failed to write to log file:", error);
|
|
1814
1807
|
}
|
|
1815
1808
|
}
|
|
1816
1809
|
function dump(...args) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/logging",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.59.
|
|
4
|
+
"version": "0.59.4",
|
|
5
5
|
"description": "The Stacks logging system.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "bun --bun build.ts",
|
|
48
48
|
"typecheck": "bun --bun tsc --noEmit",
|
|
49
|
-
"prepublishOnly": "bun
|
|
49
|
+
"prepublishOnly": "bun run build"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@stacksjs/cli": "latest",
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { appendFile } from 'node:fs/promises'
|
|
2
3
|
import { consola, createConsola } from 'consola'
|
|
3
4
|
import { ExitCode } from '@stacksjs/types'
|
|
4
5
|
import { config } from '@stacksjs/config'
|
|
@@ -45,20 +46,10 @@ export const logFilePath = logsPath('console.log')
|
|
|
45
46
|
async function writeToLogFile(message: string) {
|
|
46
47
|
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`
|
|
47
48
|
try {
|
|
48
|
-
|
|
49
|
-
const writer = file.writer()
|
|
50
|
-
const text = await file.text()
|
|
51
|
-
writer.write(`${text}\n`)
|
|
52
|
-
writer.write(`${formattedMessage}\n`)
|
|
53
|
-
await writer.end()
|
|
49
|
+
await appendFile(logFilePath, formattedMessage)
|
|
54
50
|
}
|
|
55
51
|
catch (error) {
|
|
56
|
-
|
|
57
|
-
// Create the file and then write the message
|
|
58
|
-
const file = Bun.file(logFilePath) // Use the create option
|
|
59
|
-
const writer = file.writer()
|
|
60
|
-
writer.write(`${formattedMessage}\n`)
|
|
61
|
-
await writer.end()
|
|
52
|
+
console.error('Failed to write to log file:', error)
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
55
|
|