This repository has been archived by the owner on Nov 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update electron-log and fix renderer logging
- Loading branch information
Showing
13 changed files
with
87 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as main from './main'; | ||
import * as shared from './shared'; | ||
|
||
export { | ||
main, | ||
shared, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 0 additions & 1 deletion
1
planetwars/client/app/main/index.ts → planetwars/client/app/process/main/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './logging'; | ||
export * from './app_listeners'; | ||
export * from './window'; | ||
export * from './menu'; | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './logging'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as log from 'electron-log'; | ||
|
||
/** | ||
* Set up log levels for dev and production, and allow ENV variables | ||
* configuration. | ||
*/ | ||
export function setupLogging(electronProcess: 'main' | 'render') { | ||
const { file, console: processConsole, remote } = log.transports; | ||
|
||
// In dev, set log level to debug for all transports (except remote) | ||
if (process.env.NODE_ENV === 'development') { | ||
// rendererConsole.level = "debug"; | ||
// mainConsole.level = "debug"; | ||
processConsole.level = "debug"; | ||
file.level = "debug"; | ||
remote.level = false; | ||
|
||
// In prod, set log level to verbose for all transports (except remote) | ||
} else { | ||
// rendererConsole.level = "verbose"; | ||
// mainConsole.level = "verbose"; | ||
processConsole.level = "verbose"; | ||
file.level = "info"; | ||
remote.level = false; // TODO: Would be cool to have a Sentry endpoint here | ||
} | ||
|
||
// Set log level for all transports | ||
if (process.env.BB_LOG_LEVEL) { | ||
// setLogLevelFromEnv(rendererConsole, process.env.BB_LOG_LEVEL); | ||
// setLogLevelFromEnv(mainConsole, process.env.BB_LOG_LEVEL); | ||
setLogLevelFromEnv(processConsole, process.env.BB_LOG_LEVEL); | ||
setLogLevelFromEnv(file, process.env.BB_LOG_LEVEL); | ||
setLogLevelFromEnv(remote, process.env.BB_LOG_LEVEL); | ||
} | ||
|
||
// Allow specific transport log levels to be controlled with env vars; | ||
// setLogLevelFromEnv(rendererConsole, process.env.BB_LOG_LEVEL_CONSOLE); | ||
// setLogLevelFromEnv(mainConsole!, process.env.BB_LOG_LEVEL_WEB); | ||
setLogLevelFromEnv(processConsole, process.env.BB_LOG_LEVEL_CONSOLE); | ||
setLogLevelFromEnv(file, process.env.BB_LOG_LEVEL_FILE); | ||
setLogLevelFromEnv(remote, process.env.BB_LOG_LEVEL_REMOTE); | ||
|
||
log.debug(`[STARTUP] Logging configured for ${electronProcess}-process`); | ||
log.debug(`[STARTUP] Debug logging activated for ${electronProcess}-process`); | ||
log.verbose(`[STARTUP] Verbose logging activated for ${electronProcess}-process`); | ||
} | ||
|
||
function setLogLevelFromEnv(transport: log.ITransport, envVar: string | undefined): void { | ||
const logLevels = ['silly', 'debug', 'verbose', 'info', 'warn', 'error']; | ||
if (envVar !== undefined && envVar !== "") { | ||
if (envVar === 'false') { | ||
transport.level = false; | ||
return; | ||
} | ||
if (logLevels.includes(envVar)) { | ||
transport.level = envVar as log.ILevelOption; | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2472,10 +2472,10 @@ electron-localshortcut@^3.0.0: | |
keyboardevent-from-electron-accelerator "^1.1.0" | ||
keyboardevents-areequal "^0.2.1" | ||
|
||
electron-log@^2.2.17: | ||
version "2.2.17" | ||
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.17.tgz#e71e2ebb949fc96ded7cdb99eeee7202e48981d2" | ||
integrity sha512-v+Af5W5z99ehhaLOfE9eTSXUwjzh2wFlQjz51dvkZ6ZIrET6OB/zAZPvsuwT6tm3t5x+M1r+Ed3U3xtPZYAyuQ== | ||
electron-log@^3.0.1: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-3.0.1.tgz#5c60913e8ae1a8645560eea8b3c47c60d101e797" | ||
integrity sha512-bomFcrYvkEXj0H00T5GjBee50TBA/VwdoDFpPQ2jz3LDGi+4wKF3xrB+N1qXiZYoqDeaK5lNRAkNsHKmXeCPfg== | ||
|
||
[email protected]: | ||
version "0.4.11" | ||
|
@@ -5175,7 +5175,7 @@ pkg-dir@^3.0.0: | |
version "0.0.1" | ||
dependencies: | ||
hyperscript-helpers "^3.0.3" | ||
planetwars-match-log "file:../../../../../../../../home/wout/.cache/yarn/v4/npm-planetwars-visualizer-0.0.1-f88cf828-5292-4a7f-a080-f588fc7f9073-1550433915040/node_modules/match-log" | ||
planetwars-match-log "file:../../../../../../../../home/wout/.cache/yarn/v4/npm-planetwars-visualizer-0.0.1-68fb02b6-97ba-451b-b0aa-151e8e462421-1550439613076/node_modules/match-log" | ||
react-hyperscript "^3.2.0" | ||
|
||
plist@^3.0.1: | ||
|