mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Initiate pino logger
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
"@types/unzipper": "^0.10.10",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"electron": "33.2.0",
|
||||
"pino-pretty": "^13.0.0",
|
||||
"postcss": "^8.4.49",
|
||||
"tailwindcss": "^3.4.15",
|
||||
"vite": "^5.4.11",
|
||||
@@ -99,6 +100,7 @@
|
||||
"lowlight": "^3.1.0",
|
||||
"lucide-react": "^0.460.0",
|
||||
"mime-types": "^2.1.35",
|
||||
"pino": "^9.5.0",
|
||||
"re-resizable": "^6.10.1",
|
||||
"react": "^18.3.1",
|
||||
"react-day-picker": "^8.10.1",
|
||||
|
||||
@@ -15,7 +15,9 @@ import { CommandInput } from '@/shared/commands';
|
||||
import { commandService } from '@/main/services/command-service';
|
||||
import { bootstrapper } from '@/main/bootstrapper';
|
||||
import started from 'electron-squirrel-startup';
|
||||
import { logService } from '@/main/services/log-service';
|
||||
|
||||
const logger = logService.createLogger('main');
|
||||
let subscriptionId: string | null = null;
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
@@ -76,6 +78,8 @@ const createWindow = () => {
|
||||
return assetService.handleAssetRequest(request);
|
||||
});
|
||||
}
|
||||
|
||||
logger.info('Window created');
|
||||
};
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
||||
26
apps/desktop/src/main/services/log-service.ts
Normal file
26
apps/desktop/src/main/services/log-service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { app } from 'electron';
|
||||
import pino, { Level } from 'pino';
|
||||
|
||||
const logConfig: Record<string, Level> = {
|
||||
main: 'info',
|
||||
'server-service': 'debug',
|
||||
};
|
||||
|
||||
class LogService {
|
||||
public createLogger(name: string) {
|
||||
return pino({
|
||||
name,
|
||||
level: logConfig[name] || 'info',
|
||||
transport: !app.isPackaged
|
||||
? {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const logService = new LogService();
|
||||
@@ -4,6 +4,7 @@ import { ServerConfig } from '@colanode/core';
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
import { mapServer } from '@/main/utils';
|
||||
import { eventBus } from '@/shared/lib/event-bus';
|
||||
import { logService } from '@/main/services/log-service';
|
||||
|
||||
type ServerState = {
|
||||
isAvailable: boolean;
|
||||
@@ -14,6 +15,7 @@ type ServerState = {
|
||||
|
||||
class ServerService {
|
||||
private readonly states: Map<string, ServerState> = new Map();
|
||||
private readonly logger = logService.createLogger('server-service');
|
||||
|
||||
public async syncServers() {
|
||||
const rows = await databaseService.appDatabase
|
||||
@@ -55,7 +57,7 @@ class ServerService {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(
|
||||
this.logger.info(
|
||||
`Server ${server.domain} is ${isAvailable ? 'available' : 'unavailable'}`
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user