refactor: use a standalone logger module instead of attaching it to global
(#40)
This commit is contained in:
parent
425b7fd5ff
commit
ca2d46d209
@ -1,4 +1,5 @@
|
|||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
|
import { log } from '../lib/logger';
|
||||||
|
|
||||||
const killProcesses = async pids => new Promise(resolve => exec(process.platform !== 'win32' ? `kill -9 ${pids.join(' ')}` : `taskkill /F ${pids.map(x => `/PID ${x}`).join(' ')}`, (e, out) => resolve(out)));
|
const killProcesses = async pids => new Promise(resolve => exec(process.platform !== 'win32' ? `kill -9 ${pids.join(' ')}` : `taskkill /F ${pids.map(x => `/PID ${x}`).join(' ')}`, (e, out) => resolve(out)));
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
|
|
||||||
global.log = (...args) => console.log(`[${rgb(88, 101, 242, 'Gluon')}]`, ...args);
|
|
||||||
|
|
||||||
import pkgJSON from '../package.json'
|
import pkgJSON from '../package.json'
|
||||||
|
|
||||||
process.versions.gluon = pkgJSON.version;
|
process.versions.gluon = pkgJSON.version;
|
||||||
@ -8,6 +5,7 @@ process.versions.gluon = pkgJSON.version;
|
|||||||
import { join, dirname, delimiter, sep, resolve, isAbsolute } from 'path';
|
import { join, dirname, delimiter, sep, resolve, isAbsolute } from 'path';
|
||||||
import { access, readdir } from 'fs/promises';
|
import { access, readdir } from 'fs/promises';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import { log } from './lib/logger.js';
|
||||||
|
|
||||||
import Chromium from './browser/chromium.js';
|
import Chromium from './browser/chromium.js';
|
||||||
import Firefox from './browser/firefox.js';
|
import Firefox from './browser/firefox.js';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { log } from '../lib/logger.js';
|
||||||
|
|
||||||
import IPCApi from '../lib/ipc.js';
|
import IPCApi from '../lib/ipc.js';
|
||||||
import LocalCDP from '../lib/local/cdp.js';
|
import LocalCDP from '../lib/local/cdp.js';
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
|
import { log } from '../lib/logger.js';
|
||||||
|
|
||||||
import ConnectCDP from '../lib/cdp.js';
|
import ConnectCDP from '../lib/cdp.js';
|
||||||
import InjectInto from './inject.js';
|
import InjectInto from './inject.js';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
import { get } from 'http';
|
import { get } from 'http';
|
||||||
|
import { log } from './logger';
|
||||||
|
|
||||||
const logCDP = process.argv.includes('--cdp-logging');
|
const logCDP = process.argv.includes('--cdp-logging');
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { basename, dirname, extname, join } from 'path';
|
import { basename, dirname, extname, join } from 'path';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
|
import { log } from '../logger';
|
||||||
|
|
||||||
const generatePath = (pathname, indexFile) => {
|
const generatePath = (pathname, indexFile) => {
|
||||||
if (pathname === '/') return indexFile;
|
if (pathname === '/') return indexFile;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { basename, dirname, extname, join } from 'path';
|
import { basename, dirname, extname, join } from 'path';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import { createServer } from 'http';
|
import { createServer } from 'http';
|
||||||
|
import { log } from '../logger';
|
||||||
|
|
||||||
const generatePath = (pathname, indexFile) => {
|
const generatePath = (pathname, indexFile) => {
|
||||||
if (pathname === '/') return indexFile;
|
if (pathname === '/') return indexFile;
|
||||||
|
3
src/lib/logger.js
Normal file
3
src/lib/logger.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
|
||||||
|
|
||||||
|
export const log = (...args) => console.log(`[${rgb(88, 101, 242, 'Gluon')}]`, ...args);
|
Loading…
x
Reference in New Issue
Block a user