question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Remove logging from Solid UI and add it as a module that is exposed through the data browser

See original GitHub issue

I’m currently working on the log module, which exposes a set of methods that mostly do one of three things, depending on the environment:

  1. if the environment has the document object (e.g. is a browser), it will look for an element with id “status” and append lines to it with time, type of log message and the message whenever the methods are called with a message, or
  2. if the environment supports console (e.g. Node), it will use console.log to output the messages, or
  3. do nothing

(The other methods that do not log messages are various configuration methods.)

I think it’s weird that the module is dependent on a global element somehow being available, and think it would be better to expose the API through a module that is exposed through the data browser, probably through the DataBrowserContext interface that is made available to views through methods such as render. (It is currently defined in pane-registry.)

Data browser implementations would handle logging differently, but expose the same API. This module could then be passed to methods in Solid UI that requires logging, making the need for log module in Solid UI obsolete.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
michielbdejongcommented, Mar 13, 2020

Centralizing all console.log would probably be overkilling it, since I suspect a lot of them are not intended from the developers side to manipulate a global DOM element.

I’m not implying that they should manipulate a global DOM element. I’m just saying they should not be exist in the way they exist now. In other words, I think we should activate https://eslint.org/docs/rules/no-console - I think we agree on that goal, right?

So then a simple solution is to add a function that we can call instead of it.

As a straw-man, I quickly did that here: https://github.com/solid/solid-ui/pull/267

But let’s discuss it at Monday’s standup, sounds like you’re blocked on it but I don’t think I really understand what your question is.

0reactions
megothcommented, Mar 13, 2020

I would consider the debug yes/no global more of an environment setting. I don’t see any other way to make

import { askName } from 'solid-ui'

work.

Environment setting, yes, global setting via the global scope, no. There are ways to work around these limitations, and good reasons for having them.

So let’s start by centralising all console.log into a single place where we can switch it on and off, and then for starters we just use an environment setting to do so, and if we find a cleaner way to do it in the future, then that will be a change in a single place (since the 166 places in the code where console.log is called will then already have disappeared).

I would agree with this if it where not for the current weird behavior of log module doing DOM manipulation (hence this issue). Centralizing all console.log would probably be overkilling it, since I suspect a lot of them are not intended from the developers side to manipulate a global DOM element.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5. Separation of Concerns - Programming JavaScript ... - O'Reilly
Separation of concerns is the idea that each module or layer in an application should only be responsible for one thing and should...
Read more >
Logging in Browser. Using a structured logger in your…
Frontend developers already get a lot of feedback through the UI. ... I'm wondering about the best practices of logging in a browser....
Read more >
Spring Data REST Reference Guide
These linked guides introduce how to add dependencies for the related data store, configure domain objects, and define repositories. You can run ...
Read more >
The Complete Guide to the ELK Stack - Logz.io
The Logz.io authoritative guide to the ELK Stack that shows the best practices for installation, monitoring, logging and log analysis.
Read more >
Python Logging Guide - Best Practices and Hands-on Examples
The Python standard library provides a logging module as a solution to ... Clients can add and remove filters to/from loggers using Logger....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found