This commit is contained in:
crusader 2018-10-16 22:23:33 +09:00
parent 46f9306f58
commit 5e221b0753
12 changed files with 61 additions and 24 deletions

View File

@ -12,6 +12,8 @@ import { MenuEvent } from '../commons/type';
import * as AppStore from './store/app';
import * as UserStore from './store/environment/user';
import * as log from './core/util/log';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@ -61,6 +63,8 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
ngOnInit(): void {
const __this = this;
log.info('AppComponent.ngOnInit');
this.translateService.use('en').pipe(take(1)).subscribe((res: any) => {
__this.changeDetector.detectChanges();
});

View File

@ -10,6 +10,8 @@ import { AutoHeightDirective } from '@overflow/commons/ui/directive/auto-height.
import { PingService } from '../../../service/ping.service';
import { PingOption } from '@overflow/model/config/ping';
import * as log from '../../../core/util/log';
@Component({
selector: 'app-infra-detail-host',
templateUrl: './host.component.html',
@ -64,7 +66,7 @@ export class HostComponent implements OnChanges {
this.pingWaiting = false;
}),
catchError(error => {
console.log(error);
log.error(error);
alert('An error has occurred.');
this.pingWaiting = false;
return of();

View File

@ -10,6 +10,8 @@ import { PingResult } from '@overflow/model/ping';
import { PingService } from '../../../service/ping.service';
import { PingOption } from '@overflow/model/config/ping';
import * as log from '../../../core/util/log';
@Component({
selector: 'app-infra-detail-service',
templateUrl: './service.component.html',
@ -57,14 +59,14 @@ export class ServiceComponent implements OnChanges {
this.pingService.pingService(this.service, option)
.pipe(
map((pingResult: PingResult) => {
console.log(pingResult);
log.debug(pingResult);
if (pingResult) {
this.pingResult = pingResult;
this.pingWaiting = false;
}
}),
catchError(error => {
console.log(error);
log.error(error);
alert('An error has occurred.');
this.pingWaiting = false;
return of();

View File

@ -29,6 +29,8 @@ import { DiscoveryMessageType } from 'src/app/core/type';
import { ConfirmationService } from 'primeng/primeng';
import { MetaServiceTypeEnum, toMetaServiceTypeEnum } from '@overflow/model/meta/MetaServiceType';
import * as log from '../../../core/util/log';
export class Link implements d3.SimulationLinkDatum<Node> {
source: Node;
target: Node;
@ -331,7 +333,7 @@ export class MapComponent implements OnInit, AfterContentInit, OnDestroy {
).subscribe();
}),
catchError(error => {
console.log(error);
log.error(error);
return of();
}),
).subscribe();
@ -346,7 +348,7 @@ export class MapComponent implements OnInit, AfterContentInit, OnDestroy {
__this.infraObservable.subscribe();
}),
catchError(error => {
console.log(error);
log.error(error);
return of();
}),
).subscribe();
@ -377,7 +379,7 @@ export class MapComponent implements OnInit, AfterContentInit, OnDestroy {
});
}),
catchError(error => {
console.log(error);
log.error(error);
alert('An error has occurred.');
return of();
}),
@ -774,7 +776,7 @@ export class MapComponent implements OnInit, AfterContentInit, OnDestroy {
if (width === 0 || height === 0) { return; } // nothing to fit
let scale = (paddingPercent || 0.75) / Math.max(width / fullWidth, height / fullHeight);
console.log(`scale: ${scale}`);
log.debug(`scale: ${scale}`);
if (this.maxScale < scale) {
scale = this.maxScale;

View File

@ -22,6 +22,8 @@ import { DropdownPanelComponent } from '@overflow/commons/ui/component/primeng';
import * as AppStore from '../../../store';
import * as DiscoveryConfigStore from '../../../store/discovery/config';
import * as log from '../../../core/util/log';
class NICInfo {
iface: string;
friendlyName: string;
@ -103,7 +105,7 @@ export class NicDropdownComponent implements OnInit, OnDestroy {
this.changeDetector.detectChanges();
}),
catchError(error => {
console.log(error);
log.error(error);
return of();
}),
tap(() => {

View File

@ -11,6 +11,8 @@ import { toMetaIPType, MetaIPTypeEnum, MetaPortTypeEnum } from '@overflow/model/
import * as AppStore from '../../../store';
import * as DiscoveryConfigStore from '../../../store/discovery/config';
import * as log from '../../../core/util/log';
const IPCIDR = require('ip-cidr');
@Component({
@ -61,7 +63,7 @@ export class ScannerSettingDropdownComponent implements OnInit, OnDestroy {
this.setDefault();
}),
catchError(error => {
console.log(error);
log.error(error);
return of();
}),
).subscribe();

20
src/app/core/util/log.ts Normal file
View File

@ -0,0 +1,20 @@
import * as log from 'electron-log';
export function error(...params: any[]): void {
log.error(...params);
}
export function warn(...params: any[]): void {
log.warn(...params);
}
export function info(...params: any[]): void {
log.info(...params);
}
export function verbose(...params: any[]): void {
log.verbose(...params);
}
export function debug(...params: any[]): void {
log.debug(...params);
}
export function silly(...params: any[]): void {
log.silly(...params);
}

View File

@ -8,8 +8,7 @@ import { MenuEvent } from '../../commons/type';
import { LaunchService } from './launch.service';
import { LaunchState } from '../../commons/model';
import * as _log from 'electron-log';
export const log = _log;
import * as log from '../core/util/log';
@Injectable({
providedIn: 'root'
@ -34,7 +33,7 @@ export class ElectronProxyService {
ipcRenderer.on(
'menu-event',
(event: Electron.IpcMessageEvent, { name }: { name: MenuEvent }) => {
console.log(`menu: ${name}`);
log.debug(`menu: ${name}`);
this.menuSubject.next(name);
}
);
@ -42,9 +41,9 @@ export class ElectronProxyService {
ipcRenderer.on(
'launch-timing-stats',
(event: Electron.IpcMessageEvent, { state }: { state: LaunchState }) => {
console.info(`App ready time: ${state.mainReadyTime}ms`);
console.info(`Load time: ${state.loadTime}ms`);
console.info(`Renderer ready time: ${state.rendererReadyTime}ms`);
log.info(`App ready time: ${state.mainReadyTime}ms`);
log.info(`Load time: ${state.loadTime}ms`);
log.info(`Renderer ready time: ${state.rendererReadyTime}ms`);
this.launchService
.save(state)

View File

@ -10,6 +10,8 @@ import { Subscription } from 'rxjs';
import { TypeUtil, Class, Annotation, PropertyKeyType, Method, ReflectionUtil, Decorator } from '@overflow/core-js';
import { RPCSubscriberDecoratorAttribute, RPCSubscriberDecorator } from '@overflow/commons/ui/decorator/RPCSubscriber';
import * as log from '../core/util/log';
export const requesterID = 'scannerUser';
export interface SubscriberMethod {
@ -66,7 +68,7 @@ export class ProbeService extends Client {
const subscriberMethods: SubscriberMethod[] = this.subscriberMethodMap.get(method);
if (undefined === subscriberMethods) {
console.warn(`Subscriber for method[${method}] is not exist`);
log.warn(`Subscriber for method[${method}] is not exist`);
return;
}
subscriberMethods.forEach((subscriberMethod) => {
@ -74,15 +76,15 @@ export class ProbeService extends Client {
const args = this.converNotificationParams(params, subscriberMethod.parameterTypes);
subscriberMethod.method.invoke(subscriberMethod.instance, ...args);
} catch (error) {
console.log(error);
log.error(error);
}
});
});
this.connectionStatus().subscribe(isConnected => {
if (!isConnected) {
console.log('disconnected');
log.info('disconnected');
} else {
console.log('connected');
log.info('connected');
}
});
@ -100,7 +102,7 @@ export class ProbeService extends Client {
const clazz = Class.forType(type);
if (undefined === clazz) {
console.log(`Type[${subscriber.name}] is not decorated type`);
log.warn(`Type[${subscriber.name}] is not decorated type`);
return;
}

View File

@ -8,13 +8,11 @@ import {
import * as fromRouter from '@ngrx/router-store';
import { storeFreeze } from 'ngrx-store-freeze';
import * as DiscoveryStore from './discovery';
import * as EnvironmentStore from './environment';
import * as InfraStore from './infra';
import * as UIStore from './ui';
import { environment } from '../../environments/environment';
export const EFFECTS: Type<any>[] = [

View File

@ -27,9 +27,13 @@ import { findMenuItemByID } from './menu/find-menu-item';
import { IMenuItemState } from '../commons/model/menu-update';
import * as sqlite3 from 'sqlite3';
import * as log from 'electron-log';
// enableSourceMaps();
log.transports.file.level = 'debug';
log.transports.console.level = 'debug';
let mainWindow: AppWindow | null = null;
const launchTime = now();
@ -195,7 +199,7 @@ app.on('ready', () => {
db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
if (err) {
console.error(err.message);
log.error(err.message);
}
});