Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
znorman-harris committed Dec 14, 2023
2 parents b1395d9 + bc3cbd6 commit 3ea1737
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Code style revamp! We reworked how routines, routine methods, properties, and st

- When generating ENVI and IDL tasks, using our new case libraries, we attempt to make a pretty display name from parameter names. For example converting the keyword "my_keyword" to "My Keyword". This applied to task and parameter display names.

## 4.2.1 December 2023

Fixed an issue where logs were sharing too much information and other logs were not properly reporting

## 4.2.0 December 2023

Updated the ENVI Notebook maps to no longer show "No data available" images and, instead, zoom into the highest zoom level available for basemaps
Expand Down
4 changes: 2 additions & 2 deletions apps/parsing-worker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const WORKER_THREAD_LOG_MANAGER = new LogManager({
/**
* Intercept logs and send them to our parent process
*/
WORKER_THREAD_LOG_MANAGER.interceptor = (options) => {
WORKER_THREAD_LOG_MANAGER.setInterceptor((options) => {
client.postMessage(LSP_WORKER_THREAD_MESSAGE_LOOKUP.LOG_MANAGER, options);
};
});

/**
* Create our single-threaded worker index
Expand Down
20 changes: 19 additions & 1 deletion libs/logger/src/lib/log-manager.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class LogManager implements ILogManagerOptions {
logs: { [key: string]: Logger } = {};

/** optionally set a log interceptor to interrupt any logging messages */
interceptor?: LogInterceptor;
private interceptor?: LogInterceptor;

/** Callback when we have an error */
alert: LogAlertCallback;
Expand Down Expand Up @@ -82,6 +82,19 @@ export class LogManager implements ILogManagerOptions {
}
}

/**
* Set log interceptor for everyone
*/
setInterceptor(interceptor?: LogInterceptor) {
this.interceptor = interceptor;

// update all of our logs
const logs = Object.values(this.logs);
for (let i = 0; i < logs.length; i++) {
logs[i].interceptor = interceptor;
}
}

/**
* Updates all logs to do fancy or basic logging
*/
Expand Down Expand Up @@ -134,6 +147,11 @@ export class LogManager implements ILogManagerOptions {
* @memberof LogManager
*/
log(options: ILogOptions) {
// return if debug and not debug
if (options?.type === 'debug' && !this.debug) {
return;
}

// check if we have
if (this.interceptor !== undefined) {
// get data we are sending
Expand Down
4 changes: 2 additions & 2 deletions libs/logger/src/lib/log-names.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export const IDL_TREE_CLICK_HANDLER_LOG = 'idl-tree-click-handler';
/**
* Log for debugging
*/
export const IDL_DEBUG_LOG = 'debug-idl';
export const IDL_DEBUG_LOG = 'idl-session';

/**
* Log for debugging in notebooks
*/
export const IDL_DEBUG_NOTEBOOK_LOG = 'notebook-idl';
export const IDL_DEBUG_NOTEBOOK_LOG = 'idl-notebook-session';

/**
* Log for the debug adapter
Expand Down
39 changes: 39 additions & 0 deletions libs/logger/src/lib/logger.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CleanPath } from '@idl/shared';
import * as fs from 'fs';
import * as minilog from 'minilog';

import { LogInterceptor } from './log-manager.interface';
import {
IBasicLogOptions,
LogAlertCallback,
Expand Down Expand Up @@ -62,6 +63,9 @@ export class Logger {
/** If we are quiet and dont log output to the console, still allows file logging */
quiet = false;

/** optionally set a log interceptor to interrupt any logging messages */
interceptor?: LogInterceptor;

constructor(
name: string,
enableDebugLogs = false,
Expand Down Expand Up @@ -117,6 +121,41 @@ export class Logger {
* Logs data to the console following similar API as log manager
*/
log(options: IBasicLogOptions) {
// check if we exclude debug logging items
if (!this.enableDebugLogs && options?.type === 'debug') {
return;
}

if (this.interceptor !== undefined) {
// get data we are sending
const data = options.content;

// always have an array that we log
const useData = !Array.isArray(data) ? [data] : data;

// replace any error objects
for (let i = 0; i < useData.length; i++) {
if (useData[i] instanceof Error) {
useData[i] = ObjectifyError(useData[i]);
}
}

// update property
options.content = useData;

// call our interceptor
this.interceptor({ log: this.name, ...options });

// check if we have an alert to listen for
if (options.alert) {
this.alertCb(options);
}

// return and dont do what we have below
return;
}

// log information
this.logItem(options.type, options.content);

// check if we have something to alert
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/src/lib/version.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Version of the extension
*/
export const VERSION = '4.2.0';
export const VERSION = '4.2.1';
2 changes: 1 addition & 1 deletion libs/vscode/client/src/lib/initialize-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if (process.env.VSCODE_IDL_DEBUGGING === 'true') {
);
} else {
// custom logging to send everything back to the VSCode output window
IDL_LOGGER.interceptor = CLIENT_LOG_INTERCEPTOR;
IDL_LOGGER.setInterceptor(CLIENT_LOG_INTERCEPTOR);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions libs/vscode/server/src/lib/initialize-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { InitializeCustomEventHandler } from './events/initialize-custom-event-h
import { InitializeDocumentManager } from './events/initialize-document-manager';
import { InitializeNotebookManager } from './events/initialize-notebook-manager';
import { InitializeUserInteractions } from './events/initialize-user-interactions';
import { IDL_CLIENT_CONFIG } from './helpers/track-workspace-config';
import { DEFAULT_SERVER_SETTINGS } from './settings.interface';

/**
Expand Down Expand Up @@ -72,6 +73,9 @@ export const IDL_LANGUAGE_SERVER_LOGGER = new LogManager({
},
});

// update debug logs
IDL_LANGUAGE_SERVER_LOGGER.setDebug(IDL_CLIENT_CONFIG.debugMode);

/**
* Old console.log routine
*/
Expand Down Expand Up @@ -113,12 +117,12 @@ export function InitializeServer() {
SERVER_EVENT_MANAGER = new VSCodeServerEventManager(SERVER_CONNECTION);

// intercept log messages and send to client
IDL_LANGUAGE_SERVER_LOGGER.interceptor = (options) => {
IDL_LANGUAGE_SERVER_LOGGER.setInterceptor((options) => {
SERVER_EVENT_MANAGER.sendNotification(
LANGUAGE_SERVER_MESSAGE_LOOKUP.LOG,
options
);
};
});

// // create our IDL provider object, which is the object-entry for everything so
// // we can test functionality with object methods rather than APIs
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "idl-for-vscode",
"displayName": "%packageJSON.displayName%",
"description": "%packageJSON.description%",
"version": "4.2.0",
"version": "4.2.1",
"publisher": "idl",
"license": "MIT",
"encryption": "yes",
Expand Down

0 comments on commit 3ea1737

Please sign in to comment.