Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • gjs gjs
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 128
    • Issues 128
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 27
    • Merge requests 27
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • gjsgjs
  • Issues
  • #511

Improve console output

The console methods should help to figure out what the object being logged is.

I identified the following issues so far

  1. In some cases it crashes
  2. Prints an empty object for GObject
  3. Does not print the error message of GError

log and logError are good at this, but we will need console to get better to replace log and logError with it – see #502

# actual
gjs> console.log(imports.gi.Gio)
resource:///org/gnome/gjs/modules/esm/console.js:66:17 uncaught exception: Object
...

# expected ~
gjs> console.log(imports.gi.Gio)
Gjs-Console-Message: 21:10:12.956: [object GIRepositoryNamespace Gio]

# log actual
gjs> log(imports.gi.Gio)
Gjs-Message: 21:09:23.031: JS LOG: [object GIRepositoryNamespace]
# actual
gjs> console.log(imports.gi.GLib)resource:///org/gnome/gjs/modules/esm/console.js:66:17 Error: Unions must currently be registered as boxed types
...


# expected ~
gjs> console.log(imports.gi.GLib)
Gjs-Console-Message: 21:10:12.956: [object GIRepositoryNamespace GLib]

# log actual
gjs> log(imports.gi.GLib)
Gjs-Message: 21:09:23.031: JS LOG: [object GIRepositoryNamespace]
# actual
gjs> console.log(new imports.gi.GObject.Object())
Gjs-Console-Message: 21:12:05.247: {}

# expected ~
gjs> console.log(new imports.gi.GObject.Object())
Gjs-Console-Message: 21:10:12.956: [object GType:GLocalFile] {
 // listing GObject properties would be nice 
 ... 
}

# log
gjs> log(new imports.gi.GObject.Object())
Gjs-Message: 21:31:42.128: JS LOG: [object instance wrapper GIName:GObject.Object jsobj@0x240c0f5fc80 native@0x55f2c9eccb60]
# actual
gjs> try {imports.gi.Gio.File.new_for_path('/foo').load_contents(null) } catch (err) { console.error(err) }
(gjs:68852): Gjs-Console-CRITICAL **: 21:22:41.833: {
    "stack": "@typein:7:47\n@<stdin>:1:42\n",
    "fileName": "typein",
    "lineNumber": 7,
    "columnNumber": 47
}

# expected ~
gjs> try {imports.gi.Gio.File.new_for_path('/foo').load_contents(null) } catch (err) { console.error(err) }
(gjs:68852): Gjs-Console-CRITICAL **: 21:22:41.833: Gio.IOErrorEnum: Error opening file /foo: No such file or directory
@typein:9:47
@<stdin>:1:42

# logError
gjs> try {imports.gi.Gio.File.new_for_path('/foo').load_contents(null) } catch (err) { logError(err) }
(gjs:68852): Gjs-WARNING **: 21:24:00.392: JS ERROR: Gio.IOErrorEnum: Error opening file /foo: No such file or directory
@typein:9:47
@<stdin>:1:42
# actual
gjs> console.log(new TextDecoder())
Gjs-Console-Message: 21:38:35.467: {
    "encoding": "utf-8",
    "ignoreBOM": false,
    "fatal": false
}

# expected
gjs> console.log(new TextDecoder())
Gjs-Console-Message: 21:38:35.467: TextDecoder {
    "encoding": "utf-8",
    "ignoreBOM": false,
    "fatal": false
}

# log
gjs> log(new TextDecoder())
Gjs-Message: 21:38:32.520: JS LOG: { encoding: "utf-8", ignoreBOM: false, fatal: false }

# Node.js
> console.log(new TextDecoder())
TextDecoder { encoding: 'utf-8', fatal: false, ignoreBOM: false }
Edited Oct 11, 2022 by Sonny Piers
Assignee
Assign to
Time tracking