@steambrew/client
Version:
A support library for creating plugins with Millennium.
49 lines (48 loc) • 1.87 kB
JavaScript
const bgStyle1 = 'background: #8a16a2; color: white;';
const isSharedJSContext = window.location.hostname === 'steamloopback.host';
const moduleName = isSharedJSContext ? "@steambrew/client" : "@steambrew/webkit";
export const log = (name, ...args) => {
console.log(`%c ${moduleName} %c ${name} %c`, bgStyle1, 'background: #b11cce; color: white;', 'background: transparent;', ...args);
};
export const group = (name, ...args) => {
console.group(`%c ${moduleName} %c ${name} %c`, bgStyle1, 'background: #b11cce; color: white;', 'background: transparent;', ...args);
};
export const groupEnd = (name, ...args) => {
console.groupEnd();
if (args?.length > 0)
console.log(`^ %c ${moduleName} %c ${name} %c`, bgStyle1, 'background: #b11cce; color: white;', 'background: transparent;', ...args);
};
export const debug = (name, ...args) => {
console.debug(`%c ${moduleName} %c ${name} %c`, bgStyle1, 'background: #1abc9c; color: white;', 'color: blue;', ...args);
};
export const warn = (name, ...args) => {
console.warn(`%c ${moduleName} %c ${name} %c`, bgStyle1, 'background: #ffbb00; color: white;', 'color: blue;', ...args);
};
export const error = (name, ...args) => {
console.error(`%c ${moduleName} %c ${name} %c`, bgStyle1, 'background: #FF0000;', 'background: transparent;', ...args);
};
class Logger {
constructor(name) {
this.name = name;
this.name = name;
}
log(...args) {
log(this.name, ...args);
}
debug(...args) {
debug(this.name, ...args);
}
warn(...args) {
warn(this.name, ...args);
}
error(...args) {
error(this.name, ...args);
}
group(...args) {
group(this.name, ...args);
}
groupEnd(...args) {
groupEnd(this.name, ...args);
}
}
export default Logger;