Skip to content

Commit

Permalink
chore: group logging settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirtz committed Jun 17, 2022
1 parent a3dbc1d commit d47b2c4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
31 changes: 28 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
},
"parquet-viewer.logPanel": {
"description": "Write diagnostic logs to an output panel",
"type": "boolean"
"type": "boolean",
"markdownDeprecationMessage": "**Deprecated**: Please use `#parquet-viewer.logging.panel#` instead."
},
"parquet-viewer.logFolder": {
"description": "Write diagnostic logs under the given directory",
"type": "string"
"type": "string",
"markdownDeprecationMessage": "**Deprecated**: Please use `#parquet-viewer.logging.folder#` instead."
},
"parquet-viewer.logLevel": {
"description": "Log level",
Expand All @@ -65,11 +67,34 @@
"debug",
"trace"
],
"default": "info"
"default": "info",
"markdownDeprecationMessage": "**Deprecated**: Please use `#parquet-viewer.logging.level#` instead."
},
"parquet-viewer.useParquetTools": {
"description": "use legacy parquet-tools application for reading parquet files",
"type": "boolean"
},
"parquet-viewer.logging.panel": {
"description": "Write diagnostic logs to an output panel",
"type": "boolean"
},
"parquet-viewer.logging.folder": {
"description": "Write diagnostic logs under the given directory",
"type": "string"
},
"parquet-viewer.logging.level": {
"description": "Log level",
"type": "string",
"enum": [
"off",
"fatal",
"error",
"warn",
"info",
"debug",
"trace"
],
"default": "info"
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
initLogger(context);
getLogger().info('parquet-viewer activated');

// restart logger on configuration change
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => initLogger(context)));
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
if (e.affectsConfiguration('logging')
|| e.affectsConfiguration('logLevel')
|| e.affectsConfiguration('logPanel')
|| e.affectsConfiguration('logFolder')) {
// restart logger on log configuration change
initLogger(context);
}
}));

context.subscriptions.push(ParquetEditorProvider.register(context));
}
20 changes: 10 additions & 10 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ export async function setParquetTools(parquetTools: string | undefined): Promise
await settings().update('parquetToolsPath', parquetTools);
}

export function logPanel() : boolean {
return settings().get('logPanel', false);
export function logPanel(): boolean {
return settings().get('logging.panel', settings().get('logPanel', false));
}

export async function setLogPanel(logPanel: boolean | undefined): Promise<void> {
await settings().update('logPanel', logPanel);
await settings().update('logging.panel', logPanel);
}

export function logFolder() : string {
return settings().get('logFolder', '');
export function logFolder(): string {
return settings().get('logging.folder', settings().get('logFolder', ''));
}

export async function setLogFolder(logFolder: string | undefined): Promise<void> {
await settings().update('logFolder', logFolder);
await settings().update('logging.folder', logFolder);
}

export function logLevel() : LogLevel {
return settings().get('logLevel', 'info');
export function logLevel(): LogLevel {
return settings().get('logging.level', settings().get('logLevel', 'info'));
}

export async function setLogLevel(logLevel : LogLevel | undefined): Promise<void> {
await settings().update('logLevel', logLevel);
export async function setLogLevel(logLevel: LogLevel | undefined): Promise<void> {
await settings().update('logging.level', logLevel);
}

export function useParquetTools(): boolean {
Expand Down
3 changes: 2 additions & 1 deletion test/workspace/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parquet-viewer.parquetToolsPath": "parquet-tools-1.12.0-SNAPSHOT.jar",
"parquet-viewer.logLevel": "debug"
"parquet-viewer.logLevel": "fatal",
"parquet-viewer.logging.level": "debug"
}

0 comments on commit d47b2c4

Please sign in to comment.