init: Set console log domain

GJS added a console module that extensions may start using. To ensure that
extensions using console.log() and similar functions don't show up as
'Gjs-Console' in users' system logs, we should call setConsoleLogdomain()
with 'GNOME Shell'.

This GJS API addition is only accessible using ECMAScript Modules (ESM),
this commit moves shell startup to a small init.js module and adapts
CI jobs to either handle or ignore it.

We can drop the .jscheckignore file when future versions of SpiderMonkey
allow for compile checks without validating module specifiers.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1958>
This commit is contained in:
Evan Welsh 2021-08-20 20:42:27 -05:00 committed by Marge Bot
parent ef70364e81
commit 0d8e0025d6
7 changed files with 20 additions and 9 deletions

View File

@ -1,3 +1,8 @@
extends: extends:
- ./lint/eslintrc-gjs.yml - ./lint/eslintrc-gjs.yml
- ./lint/eslintrc-shell.yml - ./lint/eslintrc-shell.yml
overrides:
- files:
- js/ui/init.js
parserOptions:
sourceType: module

View File

@ -123,7 +123,7 @@ js_check:
- .gnome-shell.fedora:34 - .gnome-shell.fedora:34
stage: review stage: review
script: script:
- find js -name '*.js' -exec js78 -c '{}' ';' 2>&1 | tee $JS_LOG - find js -name '*.js' $(printf "! -wholename %s " $(cat .jscheckignore)) -exec js78 -c '{}' ';' 2>&1 | tee $JS_LOG
- (! grep -q . $JS_LOG) - (! grep -q . $JS_LOG)
artifacts: artifacts:
paths: paths:

1
.jscheckignore Normal file
View File

@ -0,0 +1 @@
js/ui/init.js

View File

@ -64,6 +64,7 @@
<file>ui/ibusCandidatePopup.js</file> <file>ui/ibusCandidatePopup.js</file>
<file>ui/iconGrid.js</file> <file>ui/iconGrid.js</file>
<file>ui/inhibitShortcutsDialog.js</file> <file>ui/inhibitShortcutsDialog.js</file>
<file>ui/init.js</file>
<file>ui/kbdA11yDialog.js</file> <file>ui/kbdA11yDialog.js</file>
<file>ui/keyboard.js</file> <file>ui/keyboard.js</file>
<file>ui/layout.js</file> <file>ui/layout.js</file>

6
js/ui/init.js Normal file
View File

@ -0,0 +1,6 @@
import { setConsoleLogDomain } from 'console';
setConsoleLogDomain('GNOME Shell');
imports.ui.environment.init();
imports.ui.main.start();

View File

@ -1,3 +1,4 @@
data/org.gnome.Shell@wayland.service.in data/org.gnome.Shell@wayland.service.in
data/org.gnome.Shell@x11.service.in data/org.gnome.Shell@x11.service.in
js/ui/init.js
subprojects/extensions-tool/src/templates/indicator/extension.js subprojects/extensions-tool/src/templates/indicator/extension.js

View File

@ -106,7 +106,7 @@ gnome_shell_plugin_start (MetaPlugin *plugin)
{ {
GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin); GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
GError *error = NULL; GError *error = NULL;
int status; uint8_t status;
GjsContext *gjs_context; GjsContext *gjs_context;
ClutterBackend *backend; ClutterBackend *backend;
@ -126,11 +126,8 @@ gnome_shell_plugin_start (MetaPlugin *plugin)
gjs_context = _shell_global_get_gjs_context (shell_plugin->global); gjs_context = _shell_global_get_gjs_context (shell_plugin->global);
if (!gjs_context_eval (gjs_context, if (!gjs_context_eval_module_file (gjs_context,
"imports.ui.environment.init();" "resource:///org/gnome/shell/ui/init.js",
"imports.ui.main.start();",
-1,
"<main>",
&status, &status,
&error)) &error))
{ {