For Devs

Logging

We use the electron-log package for logging. It exports a logger which saves logs in locations native to the OS. For more details, refer to their documentation.

Usage

Since it is a node package, and we don’t use Electron’s nodeIntegration for security reasons, the log package can be imported as such:

import { log } from './nodeImports'

log.info("Info Log") // to log information

log.error("Error Log") // to log errors

We already have the options for catching and logging unhandled errors configured within preload.js.

const res = remote.dialog.showMessageBoxSync({
    title: 'We\'re Sorry!',
    message: 'A critical error occurred that we did not expect',
    detail: `But no worries! We\'ve collected some diagnostic information in a file and 
            will appreciate it if you can send it to us at team@sms-it.io\n
            You can find the file below:

            on Windows: Your User Folder\\AppData\\Roaming\\sms-it\\logs\\renderer.log
            on macOS: ~/Library/Logs/sms-it/renderer.log
            on Linux: ~/.config/{app name}/logs/renderer.log`,
    type: 'error',
    buttons: ['Ok, I\'ll email you'],
})

You can set your own message by editing at ./ui/electron/src/preload.js.