How to use the electron-log.transports function in electron-log

To help you get started, we’ve selected a few electron-log examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cern-phone-apps / desktop-phone-app / src / common / utils / logs.js View on Github external
const { remote } = window.require('electron');
let remoteLog = {};
if (remote) {
  remoteLog = remote.require('electron-log');
} else {
  remoteLog = {
    info: () => {},
    error: () => {},
    warn: () => {}
  };
}

const logFormat = '{level} | {y}-{m}-{d} {h}:{i}:{s}:{ms} | {text}';
log.transports.file.level = false;
if (process.env.NODE_ENV === 'production') {
  log.transports.console.level = false;
} else {
  log.transports.console.level = 'debug';
  log.transports.console.format = logFormat;
}

let logger;
if (process.env.NODE_ENV !== 'production') {
  logger = log;
} else {
  logger = remoteLog;
}

(() => {
  // saving the original console.log function
  // const preservedConsoleLog = console.log;
  // const preservedConsoleError = console.error;
github eManPrague / redmine_tracker / app / main.dev.js View on Github external
} from './constants/storage';

// Utils
import IpcApiMain from './utils/IpcApiMain';
import { defaultRouting, defaultUi } from './utils/DefaultStates';
import SettingsStorage from './utils/SettingsStorage';

// Main window
import MenuBuilder from './main/MenuBuilder';
import TrayBuilder from './main/Tray';

// Initialize store to share it between windows
import configureStore from './store';

// Set level
log.transports.file.level = 'debug';
log.transports.console.level = 'debug';

log.info(app.getPath('userData'));

// Define auto updater
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'debug';
log.info('App starting...');

// Window, store, history etc. references
let mainWindow = null;
let entriesWindow = null;
let editWindow = null;
let trayBuilder = null;
let store = null;
let ipcApiMain = null;
github xiandanin / magnetW / src / main / logger.js View on Github external
import logger from 'electron-log'
import moment from 'moment'
import util from 'util'

const level = process.env.NODE_ENV === 'development' ? 'debug' : 'silly'
logger.transports.console.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}'
logger.transports.console.level = level
logger.transports.file.fileName = `${moment().format('YYYY-MM-DD')}.log`
logger.transports.file.level = level

const styles = {
  // styles
  bold: [1, 22],
  italic: [3, 23],
  underline: [4, 24],
  inverse: [7, 27],
  // grayscale
  white: [37, 39],
  grey: [90, 39],
  black: [90, 39],
  // colors
  blue: [34, 39],
  cyan: [36, 39],
  green: [32, 39],
  magenta: [35, 39],
github microsoft / Windows-Machine-Learning / Tools / WinMLDashboard / src / electronMain.js View on Github external
const {app, ipcMain, protocol, BrowserWindow, dialog} = require('electron');

const fs = require('fs');
const path = require('path');
const url = require('url');
const log = require('electron-log');

let mainWindow;

log.transports.file.level = 'info' 
log.transports.console.level = 'info'

const squirrelEvent = process.argv[1];
log.info('Squirrel event: ' + squirrelEvent);

if(require('electron-squirrel-startup'))
{
    return;
}

function interceptFileProtocol() {
    // Intercept the file protocol so that references to folders return its index.html file
    const fileProtocol = 'file';
    const cwd = process.cwd();
    protocol.interceptFileProtocol(fileProtocol, (request, callback) => {
        const fileUrl = new url.URL(request.url);
github typie / typie / src / main / helpers / AppGlobal.ts View on Github external
public static init() {
        log.transports.file.file = Path.join(__static, "typie.log");
        log.transports.file.level = "debug";
        log.transports.console.level = "debug";
        console.log = (...args) => log.debug(...args);
        console.info = (...args) => log.info(...args);
        console.warn = (...args) => log.warn(...args);
        console.error = (...args) => log.error(...args, new Error().stack);

        AppGlobal.startTime = Date.now();
        AppGlobal.setGlobal("staticPath", __static);
        AppGlobal.setGlobal("logPath", Path.join(__static, "typie.log"));
        app.disableHardwareAcceleration();
    }
github marktext / marktext / src / main / index.js View on Github external
const initializeLogger = appEnvironment => {
  log.transports.console.level = process.env.NODE_ENV === 'development' ? true : 'error'
  log.transports.rendererConsole = null
  log.transports.file.file = path.join(appEnvironment.paths.logPath, 'main.log')
  log.transports.file.level = getLogLevel()
  log.transports.file.sync = true
  log.transports.file.init()
  initExceptionLogger()
}
github FantasticFiasco / searchlight / src / main / log.ts View on Github external
export function info(context: string, ...params: any[]) {
    log.info(`${context} -`, ...params);
}

export function warn(context: string, ...params: any[]) {
    log.warn(`${context} -`, ...params);
}

export function error(context: string, ...params: any[]) {
    log.error(`${context} -`, ...params);
}

if (isDev()) {
    log.transports.console.level = 'debug';
    log.transports.file.level = 'debug';
} else {
    log.transports.console.level = false;
    log.transports.file.level = 'info';
}
github olymp / olymp / packages / electron / main.es6 View on Github external
const { autoUpdater } = require('electron-updater');
const {
  Menu,
  app,
  BrowserWindow,
  crashReporter,
  dialog,
  shell,
} = require('electron');
require('electron-debug')({ enabled: true });
const log = require('electron-log');
const { machineIdSync } = require('node-machine-id');
const os = require('os');
const elecApp = require('@electron');

log.transports.file.level = 'info';
global.MACHINE_ID_ORIGINAL = machineIdSync({ original: true });
global.MACHINE_ID = machineIdSync({ original: false });
global.MACHINE_NAME = os.hostname();

if (process.env.CRASHREPORT_URL) {
  crashReporter.start({
    productName: 'App',
    companyName: 'cool.app',
    submitURL: process.env.CRASHREPORT_URL,
    uploadToServer: true,
  });
}

log.transports.file.level = 'info';
log.info('Starting');
github bitwarden / desktop / src / services / log.service.ts View on Github external
constructor(private filter: (level: LogLevelType) => boolean = null, logDir: string = null) {
        if (log.transports == null) {
            return;
        }

        log.transports.file.level = 'info';
        if (logDir != null) {
            log.transports.file.file = path.join(logDir, 'app.log');
        }
    }