1- import * as fs from 'fs' ;
2- import * as path from 'path' ;
1+ // const log = require('electron-log');
2+ import log from 'electron-log' ;
3+ log . transports . file . fileName = 'main.log' ;
4+
5+ const debugLog = log . create ( 'debugLog' ) ;
6+ debugLog . transports . file . level = 'debug' ;
7+ debugLog . transports . file . fileName = 'debug.log' ;
8+
9+ // const log = require("electron-log");
310
411export class AppLogger {
512 //#region Instance
@@ -15,22 +22,31 @@ export class AppLogger {
1522
1623
1724 //#region Properties & Constructor
18- private _logsPath :string ;
1925 private constructor ( ) {
20- this . _logsPath = path . join ( process . env . APPDATA , "event-viewer-pp" , "logs.txt" ) ;
21- fs . writeFileSync ( this . _logsPath , '' ) ;
2226 }
2327 //#endregion Properties & Constructor
2428
2529
2630 //#region Public Api
27- public log ( message :string ) : void {
28- console . log ( message ) ;
29- this . logToFile ( message ) ;
31+ public logInfo ( message : string ) {
32+ log . info ( message ) ;
3033 }
3134
32- public logToFile ( message : string ) : void {
33- fs . appendFileSync ( this . _logsPath , `-----\n ${ new Date ( ) . toString ( ) } \n ${ message } ` ) ;
35+ public logErrorMessage ( message : string ) {
36+ log . error ( message ) ;
3437 }
38+
39+ public logError ( e : Error ) {
40+ log . error ( e ) ;
41+ }
42+
43+ public logWarn ( message : string ) {
44+ log . warn ( message ) ;
45+ }
46+
47+ public logDebug ( message : string ) {
48+ debugLog . debug ( message ) ;
49+ }
50+
3551 //#endregion Public Api
3652}
0 commit comments