How to use the electron-log.default 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 digimezzo / knowte-electron / main.js View on Github external
// Workaround: Global does not allow setting custom properties.
// We need to cast it to "any" first.
var globalAny = global;
// Workaround to send messages between Electron windows
var EventEmitter = require('events');
var GlobalEventEmitter = /** @class */ (function (_super) {
    __extends(GlobalEventEmitter, _super);
    function GlobalEventEmitter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return GlobalEventEmitter;
}(EventEmitter));
;
globalAny.globalEmitter = new GlobalEventEmitter();
// By default, electron-log logs only to file starting from level 'warn'. We also want 'info'.
electron_log_1.default.transports.file.level = 'info';
function createWindow() {
    var gotTheLock = electron_1.app.requestSingleInstanceLock();
    if (!gotTheLock) {
        electron_1.app.quit();
    }
    else {
        electron_1.app.on('second-instance', function (event, commandLine, workingDirectory) {
            // Someone tried to run a second instance, we should focus our window.
            if (mainWindow) {
                if (mainWindow.isMinimized()) {
                    mainWindow.restore();
                }
                mainWindow.focus();
            }
        });
        // Load the previous state with fallback to defaults
github digimezzo / knowte-electron / src / app / services / note.service.js View on Github external
NoteService.prototype.renameNote = function (noteId, originalNoteTitle, newNoteTitle) {
        if (!noteId || !originalNoteTitle) {
            electron_log_1.default.error("renameNote: noteId or originalNoteTitle is null");
            return new renameNoteResult_1.RenameNoteResult(collectionOperation_1.CollectionOperation.Error);
        }
        var uniqueNoteTitle = newNoteTitle.trim();
        if (uniqueNoteTitle.length === 0) {
            return new renameNoteResult_1.RenameNoteResult(collectionOperation_1.CollectionOperation.Blank);
        }
        if (originalNoteTitle === uniqueNoteTitle) {
            electron_log_1.default.error("New title is the same as old title. No rename required.");
            return new renameNoteResult_1.RenameNoteResult(collectionOperation_1.CollectionOperation.Aborted);
        }
        try {
            // 1. Make sure the new title is unique
            uniqueNoteTitle = this.getUniqueNoteNoteTitle(newNoteTitle);
            // 2. Rename the note
            var note = this.dataStore.getNote(noteId);
            note.title = uniqueNoteTitle;
github digimezzo / knowte-electron / src / app / services / note.service.js View on Github external
if (!noteId) {
            electron_log_1.default.error("updateNoteContent: noteId is null");
            return collectionOperation_1.CollectionOperation.Error;
        }
        try {
            // Update the note file on disk
            var storageDirectory = this.settings.get('storageDirectory');
            fs.writeFileSync(path.join(storageDirectory, "" + noteId + constants_1.Constants.noteExtension), jsonContent);
            // Update the note in the data store
            var note = this.dataStore.getNote(noteId);
            note.text = textContent;
            this.dataStore.updateNote(note);
            electron_log_1.default.info("Updated content for note with id=" + noteId + ".");
        }
        catch (error) {
            electron_log_1.default.error("Could not update the content for the note with id='" + noteId + "'. Cause: " + error);
            return collectionOperation_1.CollectionOperation.Error;
        }
        return collectionOperation_1.CollectionOperation.Success;
    };
    NoteService.prototype.getNoteContent = function (noteId) {
github digimezzo / knowte-electron / main.js View on Github external
noteWindow.show();
        noteWindow.focus();
    });
    // Makes links open in external browser
    var handleRedirect = function (e, url) {
        // Check that the requested url is not the current page
        if (url != noteWindow.webContents.getURL()) {
            e.preventDefault();
            require('electron').shell.openExternal(url);
        }
    };
    noteWindow.webContents.on('will-navigate', handleRedirect);
    noteWindow.webContents.on('new-window', handleRedirect);
}
try {
    electron_log_1.default.info("[App] [main] +++ Starting +++");
    // Open note windows
    electron_1.ipcMain.on('open-note-window', function (event, arg) {
        createNoteWindow(arg.notePath, arg.noteId);
    });
    // Print
    electron_1.ipcMain.on('print', function (event, content) {
        workerWindow.webContents.send('print', content);
    });
    electron_1.ipcMain.on('readyToPrint', function (event) {
        workerWindow.webContents.print({ silent: false, printBackground: true });
    });
    // PrintPDF
    electron_1.ipcMain.on('printPDF', function (event, content) {
        workerWindow.webContents.send('printPDF', content);
    });
    electron_1.ipcMain.on('readyToPrintPDF', function (event, safePath) {
github digimezzo / knowte-electron / src / app / services / collection / collection.service.js View on Github external
CollectionService.prototype.renameNote = function (noteId, newNoteTitle) {
        if (!noteId || !newNoteTitle) {
            electron_log_1.default.error("renameNote: noteId or newNoteTitle is null");
            return noteOperation_1.NoteOperation.Error;
        }
        try {
            // 1. Check if there is already a note with that title
            if (this.noteExists(newNoteTitle)) {
                return noteOperation_1.NoteOperation.Duplicate;
            }
            // 2. Rename the note
            this.dataStore.setNoteTitle(noteId, newNoteTitle);
        }
        catch (error) {
            electron_log_1.default.error("Could not rename the note with id='" + noteId + "' to '" + newNoteTitle + "'. Cause: " + error);
            return noteOperation_1.NoteOperation.Error;
        }
        var args = new noteRenamedArgs_1.NoteRenamedArgs(noteId, newNoteTitle);
        this.noteRenamed.next(args);
        return noteOperation_1.NoteOperation.Success;
    };
    CollectionService.prototype.updateNote = function (note) {
github digimezzo / knowte-electron / src / app / services / collection / collection.service.js View on Github external
this.notebookAdded$ = this.notebookAdded.asObservable();
        this.notebookRenamed = new rxjs_1.Subject();
        this.notebookRenamed$ = this.notebookRenamed.asObservable();
        this.notebookDeleted = new rxjs_1.Subject();
        this.notebookDeleted$ = this.notebookDeleted.asObservable();
        this.noteAdded = new rxjs_1.Subject();
        this.noteAdded$ = this.noteAdded.asObservable();
        this.noteDeleted = new rxjs_1.Subject();
        this.noteDeleted$ = this.noteDeleted.asObservable();
        this.noteMarkChanged = new rxjs_1.Subject();
        this.noteMarkChanged$ = this.noteMarkChanged.asObservable();
        this.noteCountersChanged = new rxjs_1.Subject();
        this.noteCountersChanged$ = this.noteCountersChanged.asObservable();
        this.noteRenamed = new rxjs_1.Subject();
        this.noteRenamed$ = this.noteRenamed.asObservable();
        electron_log_1.default.info("CollectionService");
    }
    Object.defineProperty(CollectionService.prototype, "hasDataStore", {
github Nishkalkashyap / Quark-electron / index.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var electron_1 = require("electron");
    var fs = require("fs-extra");
    var path = require("path");
    var url = require("url");
    var electron_internal_1 = require("@squirtle/api/umd/src/api/electron/electron.internal");
    var electron_updater_1 = require("electron-updater");
    var electron_log_1 = require("electron-log");
    electron_updater_1.autoUpdater.logger = electron_log_1.default;
    electron_updater_1.autoUpdater.logger['transports'].file.level = 'info';
    electron_log_1.default.info('App starting...');
    electron_1.crashReporter.start({
        productName: 'Quarkjs',
        companyName: 'Quark',
        submitURL: 'http://localhost:3000/api/app-crashes',
        uploadToServer: false
    });
    var devModeWindows = [];
    var runModeWindows = [];
    function registerListeners() {
        electron_1.ipcMain.on(electron_internal_1.IpcEvents.ADD_RUN_MODE_WINDOW, function (e, arg) {
            createOrFocusWindow(runModeWindows, arg);
        });
        electron_1.ipcMain.on(electron_internal_1.IpcEvents.ADD_DEV_MODE_WINDOW, function (e, arg) {
            createOrFocusWindow(devModeWindows, arg);
github Nishkalkashyap / Quark-electron / index.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var electron_1 = require("electron");
    var fs = require("fs-extra");
    var path = require("path");
    var url = require("url");
    var electron_internal_1 = require("@squirtle/api/umd/src/api/electron/electron.internal");
    var electron_updater_1 = require("electron-updater");
    var electron_log_1 = require("electron-log");
    electron_updater_1.autoUpdater.logger = electron_log_1.default;
    electron_updater_1.autoUpdater.logger['transports'].file.level = 'info';
    electron_log_1.default.info('App starting...');
    electron_1.crashReporter.start({
        productName: 'Quarkjs',
        companyName: 'Quark',
        submitURL: 'http://localhost:3000/api/app-crashes',
        uploadToServer: false
    });
    var devModeWindows = [];
    var runModeWindows = [];
    function registerListeners() {
        electron_1.ipcMain.on(electron_internal_1.IpcEvents.ADD_RUN_MODE_WINDOW, function (e, arg) {
            createOrFocusWindow(runModeWindows, arg);
        });
        electron_1.ipcMain.on(electron_internal_1.IpcEvents.ADD_DEV_MODE_WINDOW, function (e, arg) {
            createOrFocusWindow(devModeWindows, arg);
        });
    }