Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main-process/comfyServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class ComfyServer implements HasTelemetry {

ComfySettings.lockWrites();
await ComfyServerConfig.addAppBundledCustomNodesToConfig();
await rotateLogFiles(app.getPath('logs'), 'comfyui', 50);
await rotateLogFiles(app.getPath('logs'), LogFile.ComfyUI, 50);
return new Promise<void>((resolve, reject) => {
const comfyUILog = log.create({ logId: 'comfyui' });
comfyUILog.transports.file.fileName = LogFile.ComfyUI;
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { app, shell } from 'electron';
import { LevelOption } from 'electron-log';
import log from 'electron-log/main';

import { LogFile } from './constants';
import { DesktopApp } from './desktopApp';
import { removeAnsiCodesTransform, replaceFileLoggingTransform } from './infrastructure/structuredLogging';
import { initializeAppState } from './main-process/appState';
import { DevOverrides } from './main-process/devOverrides';
import SentryLogging from './services/sentry';
import { getTelemetry } from './services/telemetry';
import { DesktopConfig } from './store/desktopConfig';
import { rotateLogFiles } from './utils';

// Synchronous pre-start configuration
dotenv.config();
Expand Down Expand Up @@ -41,8 +43,8 @@ if (!gotTheLock) {
async function startApp() {
// Wait for electron app ready event
await new Promise<void>((resolve) => app.once('ready', () => resolve()));
await rotateLogFiles(app.getPath('logs'), LogFile.Main, 50);
log.debug('App ready');

telemetry.registerHandlers();
telemetry.track('desktop:app_ready');

Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ export function findAvailablePort(host: string, startPort: number, endPort: numb
* @param maxFiles The maximum number of log files to keep. When 0, no files are removed. Default: 50
*/
export async function rotateLogFiles(logDir: string, baseName: string, maxFiles = 50) {
const currentLogPath = path.join(logDir, `${baseName}.log`);
const currentLogPath = path.join(logDir, `${baseName}`);

try {
await fsPromises.access(logDir, fs.constants.R_OK | fs.constants.W_OK);
await fsPromises.access(currentLogPath);
} catch {
log.error('Log rotation: cannot access log dir.');
log.error('Log rotation: cannot access log dir', currentLogPath);
// TODO: Report to user
return;
}
Expand Down
Loading