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

@ -76,4 +76,4 @@
<button type="button" pButton icon="pi pi-check" (click)="displayPrint=false" label="Yes"></button> <button type="button" pButton icon="pi pi-check" (click)="displayPrint=false" label="Yes"></button>
<button type="button" pButton icon="pi pi-close" (click)="displayPrint=false" label="No" class="ui-button-secondary"></button> <button type="button" pButton icon="pi pi-close" (click)="displayPrint=false" label="No" class="ui-button-secondary"></button>
</p-footer> </p-footer>
</p-dialog> </p-dialog>

View File

@ -12,6 +12,8 @@ import { MenuEvent } from '../commons/type';
import * as AppStore from './store/app'; import * as AppStore from './store/app';
import * as UserStore from './store/environment/user'; import * as UserStore from './store/environment/user';
import * as log from './core/util/log';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
@ -61,6 +63,8 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
ngOnInit(): void { ngOnInit(): void {
const __this = this; const __this = this;
log.info('AppComponent.ngOnInit');
this.translateService.use('en').pipe(take(1)).subscribe((res: any) => { this.translateService.use('en').pipe(take(1)).subscribe((res: any) => {
__this.changeDetector.detectChanges(); __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 { PingService } from '../../../service/ping.service';
import { PingOption } from '@overflow/model/config/ping'; import { PingOption } from '@overflow/model/config/ping';
import * as log from '../../../core/util/log';
@Component({ @Component({
selector: 'app-infra-detail-host', selector: 'app-infra-detail-host',
templateUrl: './host.component.html', templateUrl: './host.component.html',
@ -64,7 +66,7 @@ export class HostComponent implements OnChanges {
this.pingWaiting = false; this.pingWaiting = false;
}), }),
catchError(error => { catchError(error => {
console.log(error); log.error(error);
alert('An error has occurred.'); alert('An error has occurred.');
this.pingWaiting = false; this.pingWaiting = false;
return of(); return of();

View File

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

View File

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

View File

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

View File

@ -11,6 +11,8 @@ import { toMetaIPType, MetaIPTypeEnum, MetaPortTypeEnum } from '@overflow/model/
import * as AppStore from '../../../store'; import * as AppStore from '../../../store';
import * as DiscoveryConfigStore from '../../../store/discovery/config'; import * as DiscoveryConfigStore from '../../../store/discovery/config';
import * as log from '../../../core/util/log';
const IPCIDR = require('ip-cidr'); const IPCIDR = require('ip-cidr');
@Component({ @Component({
@ -61,7 +63,7 @@ export class ScannerSettingDropdownComponent implements OnInit, OnDestroy {
this.setDefault(); this.setDefault();
}), }),
catchError(error => { catchError(error => {
console.log(error); log.error(error);
return of(); return of();
}), }),
).subscribe(); ).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 { LaunchService } from './launch.service';
import { LaunchState } from '../../commons/model'; import { LaunchState } from '../../commons/model';
import * as _log from 'electron-log'; import * as log from '../core/util/log';
export const log = _log;
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -34,7 +33,7 @@ export class ElectronProxyService {
ipcRenderer.on( ipcRenderer.on(
'menu-event', 'menu-event',
(event: Electron.IpcMessageEvent, { name }: { name: MenuEvent }) => { (event: Electron.IpcMessageEvent, { name }: { name: MenuEvent }) => {
console.log(`menu: ${name}`); log.debug(`menu: ${name}`);
this.menuSubject.next(name); this.menuSubject.next(name);
} }
); );
@ -42,9 +41,9 @@ export class ElectronProxyService {
ipcRenderer.on( ipcRenderer.on(
'launch-timing-stats', 'launch-timing-stats',
(event: Electron.IpcMessageEvent, { state }: { state: LaunchState }) => { (event: Electron.IpcMessageEvent, { state }: { state: LaunchState }) => {
console.info(`App ready time: ${state.mainReadyTime}ms`); log.info(`App ready time: ${state.mainReadyTime}ms`);
console.info(`Load time: ${state.loadTime}ms`); log.info(`Load time: ${state.loadTime}ms`);
console.info(`Renderer ready time: ${state.rendererReadyTime}ms`); log.info(`Renderer ready time: ${state.rendererReadyTime}ms`);
this.launchService this.launchService
.save(state) .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 { TypeUtil, Class, Annotation, PropertyKeyType, Method, ReflectionUtil, Decorator } from '@overflow/core-js';
import { RPCSubscriberDecoratorAttribute, RPCSubscriberDecorator } from '@overflow/commons/ui/decorator/RPCSubscriber'; import { RPCSubscriberDecoratorAttribute, RPCSubscriberDecorator } from '@overflow/commons/ui/decorator/RPCSubscriber';
import * as log from '../core/util/log';
export const requesterID = 'scannerUser'; export const requesterID = 'scannerUser';
export interface SubscriberMethod { export interface SubscriberMethod {
@ -66,7 +68,7 @@ export class ProbeService extends Client {
const subscriberMethods: SubscriberMethod[] = this.subscriberMethodMap.get(method); const subscriberMethods: SubscriberMethod[] = this.subscriberMethodMap.get(method);
if (undefined === subscriberMethods) { if (undefined === subscriberMethods) {
console.warn(`Subscriber for method[${method}] is not exist`); log.warn(`Subscriber for method[${method}] is not exist`);
return; return;
} }
subscriberMethods.forEach((subscriberMethod) => { subscriberMethods.forEach((subscriberMethod) => {
@ -74,15 +76,15 @@ export class ProbeService extends Client {
const args = this.converNotificationParams(params, subscriberMethod.parameterTypes); const args = this.converNotificationParams(params, subscriberMethod.parameterTypes);
subscriberMethod.method.invoke(subscriberMethod.instance, ...args); subscriberMethod.method.invoke(subscriberMethod.instance, ...args);
} catch (error) { } catch (error) {
console.log(error); log.error(error);
} }
}); });
}); });
this.connectionStatus().subscribe(isConnected => { this.connectionStatus().subscribe(isConnected => {
if (!isConnected) { if (!isConnected) {
console.log('disconnected'); log.info('disconnected');
} else { } else {
console.log('connected'); log.info('connected');
} }
}); });
@ -100,7 +102,7 @@ export class ProbeService extends Client {
const clazz = Class.forType(type); const clazz = Class.forType(type);
if (undefined === clazz) { if (undefined === clazz) {
console.log(`Type[${subscriber.name}] is not decorated type`); log.warn(`Type[${subscriber.name}] is not decorated type`);
return; return;
} }

View File

@ -8,13 +8,11 @@ import {
import * as fromRouter from '@ngrx/router-store'; import * as fromRouter from '@ngrx/router-store';
import { storeFreeze } from 'ngrx-store-freeze'; import { storeFreeze } from 'ngrx-store-freeze';
import * as DiscoveryStore from './discovery'; import * as DiscoveryStore from './discovery';
import * as EnvironmentStore from './environment'; import * as EnvironmentStore from './environment';
import * as InfraStore from './infra'; import * as InfraStore from './infra';
import * as UIStore from './ui'; import * as UIStore from './ui';
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
export const EFFECTS: Type<any>[] = [ 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 { IMenuItemState } from '../commons/model/menu-update';
import * as sqlite3 from 'sqlite3'; import * as sqlite3 from 'sqlite3';
import * as log from 'electron-log';
// enableSourceMaps(); // enableSourceMaps();
log.transports.file.level = 'debug';
log.transports.console.level = 'debug';
let mainWindow: AppWindow | null = null; let mainWindow: AppWindow | null = null;
const launchTime = now(); const launchTime = now();
@ -195,7 +199,7 @@ app.on('ready', () => {
db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => { db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
if (err) { if (err) {
console.error(err.message); log.error(err.message);
} }
}); });