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.
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).
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?
We use glitch for several node, express tutorials. So it is helpful to log things like named route parameters req.params.foo``, query strings req.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.
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?
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.
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.
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.
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.
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.
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).
I’d like to +1 the request to add a checkbox to let authors show the console output to visitors. (Leave it off by default if security is a concern)
I also built a REST API for tutorial purposes, and use the console to explain each step that is happening.
I followed the suggestion and built a version that outputs to a fake console that is served as a webpage, but because I want the API to also work normally delivering just data and not a webpage, I wound up having to maintain two different repositories, one for glitch and one for running on a standard node server.