diff --git a/index.js b/index.js index 83a8036..c7dae01 100755 --- a/index.js +++ b/index.js @@ -35,17 +35,18 @@ const release = (defaultConsole) => { const termlog = (options = {}) => { // Ensure tconsole doesn't run in production mode - if (process && process.env.NODE_ENV && process.env.NODE_ENV !== 'development') return; - - const defaultConsole = Object.assign(Object.create(Object.getPrototypeOf(console)), console); - options = { host: DEFAULT_HOST, port: DEFAULT_PORT, ssl: false, + disableEnvironmentCheck: false, ...options, } + if (!options.disableEnvironmentCheck && process && process.env.NODE_ENV && process.env.NODE_ENV !== 'development') return; + + const defaultConsole = Object.assign(Object.create(Object.getPrototypeOf(console)), console); + const ws = new WebSocket(`${options.ssl ? "wss" : "ws"}://${options.host}:${options.port}`); ws.onopen = () => { diff --git a/package.json b/package.json index 7428c73..c4aae84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "termlog", - "version": "1.1.0", + "version": "1.1.1", "description": "Console log to terminal", "type": "main", "scripts": { diff --git a/server.js b/server.js index 48175b5..f8cbb1a 100755 --- a/server.js +++ b/server.js @@ -28,6 +28,7 @@ const getTime = () => { } const out = (data, color = CWhite) => { + if (!Array.isArray(data)) data = [data]; process.stdout.write(color); process.stdout.write(getTime() + " "); console.log.apply(console, data); @@ -73,7 +74,6 @@ const startServer = (options) => { const event = JSON.parse(message); let { type, data } = event; - if (!Array.isArray(data)) data = [data]; if (!SHOWLEVELS.includes(type)) return; switch (type) {