Console Logs on HTTP Site

#1

Dear Glitches!

I am not sure how I could make it possible, but I want to show my console logs on my HTTP site from my project (http://[My project name].glitch.me). I am not sure how I can make this possible so could someone please help me? I want to do this because I don’t want to login on third-party WiFi networks just to see the current status of my bot.

Kind regards,
Soiree

#2

There’s not a built-in way to do this, but https://glitch.com/~logs-websocket-demo is a starting point for an example of using websockets to get that information. It’s not well documented, but if you want to take a look and see if it’s something you want to take a look at I can help you get an example running.

#3

Heya!

The websockets way is at this moment too hard for me to create as I’m a fairly new nodejs developer. I had something in mind like creating a console.log file and write in it with “fs” and then let the HTML page read it and outpost the content of the document, but I’m getting a error for permissions denied.

#4

The project that @Callum-OKane linked to is intended to extract the output from an arbitrary project, and it watches all of the communication between the Glitch platform and the specified project. Another option might be something like https://glitch.com/~console-mirror, which just extracts things sent to the console using console.log() and mirrors them to a webpage. It still leverages websockets under the covers because that’s how Glitch components talk to one another, but it’s probably much easier to integrate.

Your filesystem based approach may also work - can you provide your code and the full error you’re receiving or your project’s name so someone can take a closer look? My initial guess is that perhaps you’re trying to write to a path that’s not accessible by the user the project’s running under.

#5

Error: EACCES: permission denied, open ‘/consolelog.log’

Emitted ‘error’ event at:

at lazyFs.open (internal/fs/streams.js:272:12)

at FSReqWrap.args [as oncomplete] (fs.js:140:20)

var access = fs.createWriteStream(__dirname + ‘/consolelog.log’);
process.stdout.write = process.stderr.write = access.write.bind(access);

The first quote is the error and the second quote is the code that I am currently using. I am currently trying the mirror console way and I will let you guys know as fast as possible!

#6

Hello everyone!

I am back again, I tried to integrate the console-mirror code into mines and the HTML page works fine but it will only run the server.js console.logs and will ignore the console logs from my main program (bot.js). I am running the client-console.js using:

“scripts”: {
“start”: “FORCE_COLOR=true node client-console.js & node bot.js”
},
in the package.js

Does anybody know how to mirror ALL the console.logs?
If you would like to chat instantly then don’t hesitate to add me on Discord: “Soiree | Badlion#6352”.

Kind regards,
PamlaNL