Show logs without remixing


#1

Feature Request (or possible bug)

We’re using glitch for demos and tutorials and it would be great if viewers could see the logs without remixing a project. And it would be great if, when embedding or linking, we could set the logs panel to be open or closed.

  • The “Logs” button should be available for anonymous users and without remixing. BTW, I was able to get the Logs panel to show by using (Ctrl + Shift + L) but the actual logs don’t appear in the output (see screenshot below)
  • Define if the log panel is open or closed using a parameter in the URL so it can be set when providing a link or when embedding.


#2

hey cklanac,

While your use case makes total sense and we would ideally just enable logs for everyone, there are security implications that prevent us from doing so. We explicitly hide (and don’t broadcast) log messages to anon users because log messages can include potentially unsafe to share information, particularly historical info like if an editor console.logs an env var to debug.

That being said, I’ve added to our backlog that we should show an explanation about why there are no logs shown when you use the keyboard shortcut (instead of blankness).


#3

Maybe, as authors, we can choose to show logs or not? It’s similar responsibility to sharing publicly or making it private.


#4

it’s something we will certainly consider, but it’s different than marking a project as private because the potential implications of the decision are less immediately obvious.

The more info you can give us about your specific context will help as well: like what specific thing(s) are demoing and how specifically does the terminal being public help with that?


#5

We use glitch for several node, express tutorials. So it is helpful to log things like named route parameters req.params.foo``, query stringsreq.query.barheadersreq.header(field)and bodyreq.body`. And at the risk of being too on-the-nose, we’re building a webapp so it’s useful for showing errors, simple weblogs and morgan.

here’s some examples:




#6

So the tutorials look great, but I might be missing something about how they’re used/presented. Wouldn’t it make the most sense for the people learning along to Remix these projects so that they can edit them, and also be able to see the logs?


#7

You’re not missing anything, you said in your first reply that the use-case makes sense.

The glitches are embedded in normal tutorials like any tech article or post you see on the web. The tutorials describe the execution of code and the output. So yes, it makes sense that they can edit them - if they want to. But some users may also want to simply read tutorial and look at code and the output without being required to register and remix the project.


#8

you don’t need to register to remix a project. What you can do in your tutorial is link directly to the project with a remix link (if you open the browser console the link will be output there). That way when a visitor visits the project they’ll immediately be viewing their own copy, logs and all.


#9

It’s not really a viable solution. Now, every time someone visits the page they get a new remix. Their project list quickly fills up with several of copies of the same project. Providing the ability to show logs is still a better solution.

I know you’re concerned about .env secrets leaking to the public. Maybe you could allow users to show the logs if the only .env been removed, or it is unchanged or empty? That way a user could either have secrets in the .env file, or they can show the logs, but not both.


#10

Maybe you could update an element on the page instead?

You could use something like http://socket.io.


#11

The tutorials and examples are mostly about RESTful APIs so there’s no element to update.


#12

Right. You can make a simple page with a div element and use socket.io to update its content.


#13

I think introducing socket.io in “getting started with node and express” demos would confuse and distract most readers. I’d like to keep the tutorials clean and focused on the topic. Enabling logs is a much cleaner solution.


#14

Would it be possible to have the users open the inspector in their browser and view the console.log thru the javascript console?


#15

One other suggestion, you could, with a couple lines of code, redirect stdout to a file on the file system which should effectively work around the issue. There are people who might be put off by their IP address appearing in the log for anyone to view though, so there are “privacy” concerns to think about. As for the copies of the projects they can always just delete whatever they don’t need under advanced options.


#16

Maybe there should be a way to make a link that will remix as an anonymous user?

Then the user can see the output in the console, make changes, and remix the changes into their own account if they actually want to save it. This would be great for an embedded jsbin / gist / code pen style viewer.

As a user I would find it strange if each blog I visited created new projects in my account if I was logged in (which sounds like what may happen if a remix url was used in an iframe, but I have not tried).


Private information on Glitch instances