Skip to content

Commit

Permalink
Revert "Fix logging"
Browse files Browse the repository at this point in the history
This reverts commit 9e2a9d5.
  • Loading branch information
bcomnes committed Dec 24, 2023
1 parent ccddee9 commit b55d6f6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
15 changes: 12 additions & 3 deletions main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ const makeTrackDict = require('./track-dict')
const audio = require('./windows/audio')
const player = require('./windows/player')
const AudioLibrary = require('./lib/audio-library')
const log = require('electron-log')
const autoUpdater = require('electron-updater').autoUpdater

// handle uncaught exceptions before calling any functions
process.on('uncaughtException', (err) => {
console.error(err)
log.error(err)
})

const windows = [player, audio]
Expand Down Expand Up @@ -64,7 +65,7 @@ app.on('ready', function appReady () {
artwork.init()

electron.powerMonitor.on('suspend', function pauseOnWake () {
broadcast('log', 'Entering sleep, pausing')
log.info('Entering sleep, pausing')
ipcMain.emit('pause')
})

Expand All @@ -91,7 +92,7 @@ app.on('ready', function appReady () {
// register autoUpdater
if (!process.env.DEV_SERVER) {
setTimeout(() => {
broadcast('log', 'autoUpdater: Auto update initalized...')
log.info('autoUpdater: Auto update initalized...')
autoUpdater.checkForUpdatesAndNotify()
}, 1000 * 3)
}
Expand All @@ -103,16 +104,19 @@ app.on('ready', function appReady () {

autoUpdater.on('checking-for-update', () => {
broadcast('log', 'autoUpdater: Checking for update...')
log.info('autoUpdater: Checking for update...')
broadcast('au:checking-for-update')
})

autoUpdater.on('update-available', (info) => {
broadcast('log', 'autoUpdater: Update available!')
log.info('autoUpdater: Update available!')
broadcast('au:update-available', info)
})

autoUpdater.on('update-not-available', (info) => {
broadcast('log', 'autoUpdater: No update available')
log.info('autoUpdater: No update available')
broadcast('au:update-not-available', info)
})

Expand All @@ -122,6 +126,7 @@ app.on('ready', function appReady () {

autoUpdater.on('update-downloaded', (info) => {
broadcast('log', 'autoUpdater: Update downloaded')
log.info('autoUpdater: Update downloaded')
broadcast('au:update-downloaded', info)
})

Expand All @@ -146,6 +151,7 @@ app.on('ready', function appReady () {
function queue (ev, newIndex) {
const newTrack = al.queue(newIndex)
broadcast('log', newTrack)
log.info(newTrack)
broadcast('new-track', newTrack)
if (player.win) {
player.win.send('new-index', al.index)
Expand All @@ -163,6 +169,7 @@ app.on('ready', function appReady () {

function handleGetPath (err, blobPath) {
if (err) return broadcast('log', err)
if (err) return log.error(err)
al.currentTrack.artwork = blobPath
if (player.win) {
player.win.send('new-track', al.currentTrack)
Expand Down Expand Up @@ -247,10 +254,12 @@ app.on('ready', function appReady () {
state.loading = false
broadcast('loading', false)
if (err) return broadcast('log', err)
if (err) return log.warn(err)
const newState = al.load(newTrackDict)
if (player.win) player.win.send('track-dict', newState.trackDict, newState.order, state.paths)
console.timeEnd('update-library')
broadcast('log', 'Done scanning. Found ' + Object.keys(newState.trackDict).length + ' tracks.')
log.info('Done scanning. Found ' + Object.keys(newState.trackDict).length + ' tracks.')
}

function updateLibrary (ev, paths) {
Expand Down
1 change: 1 addition & 0 deletions main/track-dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const mm = require('music-metadata')
const writer = require('flush-write-stream')
const filter = require('through2-filter')
const pump = require('pump')
const log = require('electron-log')
const validExtensions = ['m4a', 'mp3', 'ogg']

module.exports = makeTrackDict
Expand Down
3 changes: 2 additions & 1 deletion main/windows/audio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { app, BrowserWindow } = require('electron')
const path = require('path')
const log = require('electron-log')
const remoteMain = require('@electron/remote/main')
const AUDIO_WINDOW = 'file://' + path.resolve(__dirname, '..', '..', 'renderer', 'audio', 'index.html')
const audio = module.exports = {
Expand Down Expand Up @@ -52,7 +53,7 @@ function show () {

function toggleDevTools () {
if (!audio.win) return
console.log('[AUDIO] Toggling dev tools')
log.info('[AUDIO] Toggling dev tools')
if (audio.win.webContents.isDevToolsOpened()) {
audio.win.webContents.closeDevTools()
audio.win.hide()
Expand Down
3 changes: 2 additions & 1 deletion main/windows/player.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { BrowserWindow, app } = require('electron')
const windowStateKeeper = require('electron-window-state')
const path = require('path')
const log = require('electron-log')
const remoteMain = require('@electron/remote/main')
const PLAYER_WINDOW = 'file://' + path.resolve(__dirname, '..', '..', 'renderer', 'player', 'index.html')

Expand Down Expand Up @@ -62,7 +63,7 @@ function init () {

function toggleAlwaysOnTop () {
if (!player.win) return
console.log('[PLAYER] Toggling Always on Top')
log.info('[PLAYER] Toggling Always on Top')
if (player.win.isAlwaysOnTop()) {
alwaysOnTop = false
player.win.setAlwaysOnTop(alwaysOnTop)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"electron-context-menu": "^3.6.1",
"electron-debug": "^3.0.1",
"electron-default-menu": "^1.0.1",
"electron-log": "^5.0.0-beta.16",
"electron-store": "^8.1.0",
"electron-updater": "^6.1.7",
"electron-window-state": "^5.0.2",
Expand Down

0 comments on commit b55d6f6

Please sign in to comment.