Skip to content

Commit 80060cf

Browse files
authored
Centralize logs when not in a firebase directory (#7811)
* Centralize logs when not in a firebase directory * PR fixes * PR fixes
1 parent 82bfe47 commit 80060cf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

firebase-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## NEXT
22

3+
- Fixed an issue where log files would be written to non-Firebase directories.
4+
35
## 0.10.3
46

57
- Updated internal firebase-tools dependency to 13.21.0

firebase-vscode/src/logger-wrapper.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as path from "path";
22
import * as vscode from "vscode";
3+
import * as fs from "fs";
4+
import * as os from "os";
35
import { transports, format } from "winston";
46
import Transport from "winston-transport";
57
import stripAnsi from "strip-ansi";
@@ -45,7 +47,11 @@ export function logSetup() {
4547
// Re-implement file logger call from ../../src/bin/firebase.ts to not bring
4648
// in the entire firebase.ts file
4749
const rootFolders = getRootFolders();
48-
const filePath = path.join(rootFolders[0], ".firebase", "logs", "vsce-debug.log");
50+
// Default to a central path, but write files to a local path if we're in a Firebase directory.
51+
let filePath = path.join(os.homedir(), ".cache", "firebase", "logs", "vsce-debug.log");
52+
if (fs.existsSync(path.join(rootFolders[0], "firebase.json"))) {
53+
filePath = path.join(rootFolders[0], ".firebase", "logs", "vsce-debug.log");
54+
}
4955
pluginLogger.info("Logging to path", filePath);
5056
cliLogger.add(
5157
new transports.File({

0 commit comments

Comments
 (0)