Skip to content

A package to log your IPv4 address and port to your terminal, so you can debug on other devices like your phone.

License

Notifications You must be signed in to change notification settings

Jelmerovereem/localhost-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

localhost-logger

A zero-dependency utility for logging your local network IPv4 address to the console. Useful for testing web apps on other devices.

Usage

CommonJS syntax

const port = 7000; // can be any number
app.listen(port, () => { // express syntax
	if (process.env.NODE_ENV !== 'production') { // NODE_ENV is usually set to 'production' on hosting platforms like Heroku.
		const localLog = require("localhost-logger"); // Require localLog here, so it won't be used in a production environment.
		localLog(port); // logs: 192.XXX.X.X:port
	}
	console.log(`Server is running on port ${port}`);
})

ES6 syntax

const port = 7000; // can be any number
app.listen(port, () => { // express syntax
	if (process.env.NODE_ENV !== 'production') { // NODE_ENV is usually set to 'production' on hosting platforms like Heroku.
		import("localhost-logger").then((localLog) => { // Import localLog here, so it won't be used in a production environment.
			localLog.default(port); // logs: 192.XXX.X.X:port
		});
	}
	console.log(`Server is running on port ${port}`);
})

Installation

Install to your devDependencies, so you won't use it on production level.

$ npm install localhost-logger --save-dev

About

A package to log your IPv4 address and port to your terminal, so you can debug on other devices like your phone.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages