Browse Source

Move notebook output logging extension to notebook-extension from logconsole-extension.

Jason Grout 5 years ago
parent
commit
9ca9883b74

+ 0 - 2
packages/logconsole-extension/package.json

@@ -38,10 +38,8 @@
     "@jupyterlab/coreutils": "^5.0.0-alpha.14",
     "@jupyterlab/logconsole": "^3.0.0-alpha.14",
     "@jupyterlab/mainmenu": "^3.0.0-alpha.14",
-    "@jupyterlab/nbformat": "^3.0.0-alpha.14",
     "@jupyterlab/notebook": "^3.0.0-alpha.14",
     "@jupyterlab/rendermime": "^3.0.0-alpha.14",
-    "@jupyterlab/services": "^6.0.0-alpha.14",
     "@jupyterlab/settingregistry": "^3.0.0-alpha.14",
     "@jupyterlab/statusbar": "^3.0.0-alpha.14",
     "@jupyterlab/translation": "^3.0.0-alpha.14",

+ 1 - 3
packages/logconsole-extension/src/index.tsx

@@ -54,8 +54,6 @@ import { DockLayout, Widget } from '@lumino/widgets';
 
 import * as React from 'react';
 
-import { logNotebookOutput } from './nboutput';
-
 import { LogConsoleStatus } from './status';
 
 const LOG_CONSOLE_PLUGIN_ID = '@jupyterlab/logconsole-extension:plugin';
@@ -424,4 +422,4 @@ export class LogLevelSwitcher extends ReactWidget {
   private _id = `level-${UUID.uuid4()}`;
 }
 
-export default [logConsolePlugin, logNotebookOutput];
+export default logConsolePlugin;

+ 0 - 6
packages/logconsole-extension/tsconfig.json

@@ -21,18 +21,12 @@
     {
       "path": "../mainmenu"
     },
-    {
-      "path": "../nbformat"
-    },
     {
       "path": "../notebook"
     },
     {
       "path": "../rendermime"
     },
-    {
-      "path": "../services"
-    },
     {
       "path": "../settingregistry"
     },

+ 1 - 0
packages/notebook-extension/package.json

@@ -44,6 +44,7 @@
     "@jupyterlab/docmanager": "^3.0.0-alpha.14",
     "@jupyterlab/filebrowser": "^3.0.0-alpha.14",
     "@jupyterlab/launcher": "^3.0.0-alpha.14",
+    "@jupyterlab/logconsole": "^3.0.0-alpha.14",
     "@jupyterlab/mainmenu": "^3.0.0-alpha.14",
     "@jupyterlab/nbformat": "^3.0.0-alpha.14",
     "@jupyterlab/notebook": "^3.0.0-alpha.14",

+ 4 - 1
packages/notebook-extension/src/index.ts

@@ -91,6 +91,8 @@ import { Message, MessageLoop } from '@lumino/messaging';
 
 import { Panel, Menu } from '@lumino/widgets';
 
+import { logNotebookOutput } from './nboutput';
+
 /**
  * The command IDs used by the notebook plugin.
  */
@@ -398,7 +400,8 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
   tools,
   commandEditItem,
   notebookTrustItem,
-  widgetFactoryPlugin
+  widgetFactoryPlugin,
+  logNotebookOutput
 ];
 export default plugins;
 

+ 10 - 5
packages/logconsole-extension/src/nboutput.ts → packages/notebook-extension/src/nboutput.ts

@@ -19,16 +19,21 @@ import { KernelMessage } from '@jupyterlab/services';
  */
 export const logNotebookOutput: JupyterFrontEndPlugin<void> = {
   activate: activateNBOutput,
-  id: '@jupyterlab/logconsole:nboutput',
-  requires: [ILoggerRegistry, INotebookTracker],
+  id: '@jupyterlab/notebook-extension:log-output',
+  requires: [INotebookTracker],
+  optional: [ILoggerRegistry],
   autoStart: true
 };
 
 function activateNBOutput(
   app: JupyterFrontEnd,
-  loggerRegistry: ILoggerRegistry,
-  nbtracker: INotebookTracker
+  nbtracker: INotebookTracker,
+  loggerRegistry: ILoggerRegistry | null
 ) {
+  if (!loggerRegistry) {
+    // Automatically disable if logconsole is missing
+    return;
+  }
   function registerNB(nb: NotebookPanel) {
     function logOutput(
       msg: KernelMessage.IIOPubMessage,
@@ -41,7 +46,7 @@ function activateNBOutput(
         KernelMessage.isErrorMsg(msg) ||
         KernelMessage.isExecuteResultMsg(msg)
       ) {
-        const logger = loggerRegistry.getLogger(nb.context.path);
+        const logger = loggerRegistry!.getLogger(nb.context.path);
         logger.rendermime = nb.content.rendermime;
         const data: nbformat.IOutput = {
           ...msg.content,

+ 3 - 0
packages/notebook-extension/tsconfig.json

@@ -30,6 +30,9 @@
     {
       "path": "../launcher"
     },
+    {
+      "path": "../logconsole"
+    },
     {
       "path": "../mainmenu"
     },