🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

gould

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gould

**Gould** is a super simple Node module to display your backend console logs on the frontend console. It works by the following steps:

latest
npmnpm
Version
1.3.0
Version published
Weekly downloads
21
Maintainers
1
Weekly downloads
 
Created
Source

#Gould

Gould is a super simple Node module to display your backend console logs on the frontend console. It works by the following steps:

  • Writing the backend logs to a file called 'temp.log'
  • Establishing a socket connection with the frontend using 'socket.io'
  • Utilizing the 'fs' module's 'watch' method to watch for every new log message
  • Utilizing the 'fs' module's 'read' method to get each new log message from 'temp.log'
  • Piping each of these messages to the front end socket
  • Console logging the messages once they arrive on the front end

The process is nearly simultaneous.

Setup is easy. On your backend app.js or server.js file, ensure you initialize a server using http:

const server = http.createServer(app);

On the front end of any page where you want simultaneous logging, simply include the following lines, switching out the appropriate localhost port or remote URL as needed:

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.2/socket.io.min.js"> </script>
<script type="text/javascript">
    let socket = io.connect('http://localhost:3000');
    socket.on('stuff', function (data) {
      console.log(data);
    });
</script>

That's it. You're done.

Notes: Gould must be required after server instantiated This is for express

FAQs

Package last updated on 17 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts