1.0.7 • Published 3 years ago

localhost-logger v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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
1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago