chore: 移除loggerservice

This commit is contained in:
thinkinggis 2021-08-05 17:29:13 +08:00
parent 5aeddc763b
commit 973b8d1db2
24 changed files with 18 additions and 126 deletions

View File

@ -44,7 +44,6 @@ export * from './services/asset/IFontService';
export * from './services/component/IControlService';
export * from './services/component/IMarkerService';
export * from './services/component/IPopupService';
export * from './services/log/ILogService';
export * from './services/interaction/IInteractionService';
export * from './services/interaction/IPickingService';

View File

@ -20,7 +20,6 @@ import { IInteractionService } from './services/interaction/IInteractionService'
import { IPickingService } from './services/interaction/IPickingService';
import { ILayerService } from './services/layer/ILayerService';
import { IStyleAttributeService } from './services/layer/IStyleAttributeService';
import { ILogService } from './services/log/ILogService';
import { ISceneService } from './services/scene/ISceneService';
import { IShaderModuleService } from './services/shader/IShaderModuleService';
@ -37,7 +36,6 @@ import InteractionService from './services/interaction/InteractionService';
import PickingService from './services/interaction/PickingService';
import LayerService from './services/layer/LayerService';
import StyleAttributeService from './services/layer/StyleAttributeService';
import LogService from './services/log/LogService';
import SceneService from './services/scene/SceneService';
import ShaderModuleService from './services/shader/ShaderModuleService';
@ -83,10 +81,6 @@ container
.bind<IShaderModuleService>(TYPES.IShaderModuleService)
.to(ShaderModuleService)
.inSingletonScope();
container
.bind<ILogService>(TYPES.ILogService)
.to(LogService)
.inSingletonScope();
// container
// .bind<IFontService>(TYPES.IFontService)
// .to(FontService)

View File

@ -4,7 +4,6 @@ import { inject, injectable } from 'inversify';
import 'reflect-metadata';
// @ts-ignore
import { TYPES } from '../../types';
import { ILogService } from '../log/ILogService';
import { ILngLat, IMapService } from '../map/IMapService';
import { IInteractionService, InteractionEvent } from './IInteractionService';
const DragEventMap: { [key: string]: string } = {
@ -23,9 +22,6 @@ export default class InteractionService extends EventEmitter
@inject(TYPES.IMapService)
private readonly mapService: IMapService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
private hammertime: HammerManager;
private lastClickTime: number = 0;
@ -92,7 +88,6 @@ export default class InteractionService extends EventEmitter
this.hammertime = hammertime;
// TODO: 根据场景注册事件到 L7 canvas 上
this.logger.debug('add event listeners on canvas');
}
}
private removeEventListenerOnMap() {

View File

@ -1,6 +0,0 @@
export interface ILogService {
error(message: string): void;
warn(message: string): void;
info(message: string): void;
debug(message: string): void;
}

View File

@ -1,29 +0,0 @@
import { injectable } from 'inversify';
import Probe, { Log } from 'probe.gl';
import { ILogService } from './ILogService';
// !process.env.NODE_ENV === 'production',
const Logger = new Log({ id: 'L7' }).enable(
// @ts-ignore
process.env.NODE_ENV !== 'production',
);
// // 只输出 debug 级别以上的日志信息
Logger.priority = 5;
@injectable()
export default class LogService implements ILogService {
public error(message: string): void {
Logger.error(message)();
}
public warn(message: string): void {
Logger.probe(1, message)();
}
public info(message: string): void {
Logger.info(3, message)();
}
public debug(message: string): void {
Logger.probe(4, message)();
}
}

View File

@ -7,7 +7,6 @@ import {
InteractionEvent,
} from '../../interaction/IInteractionService';
import { ILayer } from '../../layer/ILayerService';
import { ILogService } from '../../log/ILogService';
import { ILngLat } from '../../map/IMapService';
import { gl } from '../gl';
import { IFramebuffer } from '../IFramebuffer';
@ -22,9 +21,6 @@ import BaseNormalPass from './BaseNormalPass';
export default class PixelPickingPass<
InitializationOptions = {}
> extends BaseNormalPass<InitializationOptions> {
@inject(TYPES.ILogService)
protected readonly logger: ILogService;
/**
* picking framebuffer attributes
*/
@ -170,7 +166,6 @@ export default class PixelPickingPass<
pickedColors[1] !== 0 ||
pickedColors[2] !== 0
) {
this.logger.debug('picked');
const pickedFeatureIdx = decodePickingColor(pickedColors);
const rawFeature = this.layer
.getSource()

View File

@ -5,7 +5,6 @@ import copyFS from '../../../shaders/post-processing/copy.glsl';
import quadVS from '../../../shaders/post-processing/quad.glsl';
import { TYPES } from '../../../types';
import { ILayer } from '../../layer/ILayerService';
import { ILogService } from '../../log/ILogService';
import { IShaderModuleService } from '../../shader/IShaderModuleService';
import { gl } from '../gl';
import { IFramebuffer } from '../IFramebuffer';
@ -43,9 +42,6 @@ export default class TAAPass<InitializationOptions = {}> extends BaseNormalPass<
@inject(TYPES.IShaderModuleService)
protected readonly shaderModuleService: IShaderModuleService;
@inject(TYPES.ILogService)
protected readonly logger: ILogService;
/**
*
*/
@ -193,8 +189,6 @@ export default class TAAPass<InitializationOptions = {}> extends BaseNormalPass<
}
private doRender(layer: ILayer) {
this.logger.debug(`accumulatingId: ${this.accumulatingId}`);
const { clear, getViewportSize, useFramebuffer } = this.rendererService;
const { width, height } = getViewportSize();
const { jitterScale = 1 } = layer.getLayerConfig();

View File

@ -22,7 +22,6 @@ import {
} from '../interaction/IInteractionService';
import { IPickingService } from '../interaction/IPickingService';
import { ILayer, ILayerService } from '../layer/ILayerService';
import { ILogService } from '../log/ILogService';
import { IMapCamera, IMapConfig, IMapService } from '../map/IMapService';
import { IRenderConfig, IRendererService } from '../renderer/IRendererService';
import { IShaderModuleService } from '../shader/IShaderModuleService';
@ -55,9 +54,6 @@ export default class Scene extends EventEmitter implements ISceneService {
@inject(TYPES.IControlService)
private readonly controlService: IControlService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@ -184,7 +180,6 @@ export default class Scene extends EventEmitter implements ISceneService {
InteractionEvent.Drag,
this.addSceneEvent.bind(this),
);
this.logger.debug(`map ${this.id} loaded`);
});
/**
@ -220,11 +215,10 @@ export default class Scene extends EventEmitter implements ISceneService {
.matchMedia('screen and (-webkit-min-device-pixel-ratio: 1.5)')
.addListener(this.handleWindowResized);
} else {
this.logger.error('容器 id 不存在');
console.error('容器 id 不存在');
}
this.pickingService.init(this.id);
this.logger.debug(`scene ${this.id} renderer loaded`);
});
// TODOinit worker, fontAtlas...
@ -235,7 +229,6 @@ export default class Scene extends EventEmitter implements ISceneService {
}
public addLayer(layer: ILayer) {
this.logger.debug(`add layer ${layer.name} to scene ${this.id}`);
this.layerService.add(layer);
this.render();
}
@ -259,7 +252,6 @@ export default class Scene extends EventEmitter implements ISceneService {
await document.fonts.load(`24px ${this.fontFamily}`, 'L7text');
}
// FIXME: 初始化 marker 容器,可以放到 map 初始化方法中?
this.logger.info(' render inited');
this.layerService.initLayers();
this.controlService.addControls();
this.loaded = true;
@ -271,7 +263,6 @@ export default class Scene extends EventEmitter implements ISceneService {
this.layerService.renderLayers();
// 组件需要等待layer 初始化完成之后添加
this.logger.debug(`scene ${this.id} render`);
this.rendering = false;
}

View File

@ -7,7 +7,6 @@ const TYPES = {
ILayerService: Symbol.for('ILayerService'),
ILayerMappingService: Symbol.for('ILayerMappingService'),
ILayerStyleService: Symbol.for('ILayerStyleService'),
ILogService: Symbol.for('ILogService'),
IMapService: Symbol.for('IMapService'),
IMarkerService: Symbol.for('IMarkerService'),
IPopupService: Symbol.for('PopupService'),

View File

@ -19,7 +19,6 @@ import {
ILayerModelInitializationOptions,
ILayerPlugin,
ILayerService,
ILogService,
IMapService,
IModel,
IModelInitializationOptions,
@ -112,9 +111,6 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
public layerModel: ILayerModel;
@lazyInject(TYPES.ILogService)
protected readonly logger: ILogService;
@lazyInject(TYPES.IGlobalConfigService)
protected readonly configService: IGlobalConfigService;

View File

@ -4,7 +4,6 @@ import {
IEncodeFeature,
ILayer,
ILayerPlugin,
ILogService,
IModel,
IModelUniform,
IRasterParserDataItem,

View File

@ -5,7 +5,6 @@ import {
ILayer,
ILayerPlugin,
ILngLat,
ILogService,
IMapService,
IParseDataItem,
IStyleAttribute,
@ -22,9 +21,6 @@ export default class DataMappingPlugin implements ILayerPlugin {
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
@inject(TYPES.IMapService)
private readonly mapService: IMapService;
@ -80,7 +76,6 @@ export default class DataMappingPlugin implements ILayerPlugin {
),
);
}
this.logger.debug('remapping finished');
// 处理文本更新
layer.emit('remapping', null);
}

View File

@ -2,7 +2,6 @@ import {
IGlobalConfigService,
ILayer,
ILayerPlugin,
ILogService,
IScale,
IScaleOptions,
IStyleAttribute,
@ -41,10 +40,6 @@ const scaleMap = {
export default class FeatureScalePlugin implements ILayerPlugin {
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
// key = field_attribute name
private scaleCache: {
[field: string]: IStyleScale;
@ -97,7 +92,6 @@ export default class FeatureScalePlugin implements ILayerPlugin {
);
if (attributesToRescale.length) {
this.caculateScalesForAttributes(attributesToRescale, dataArray);
this.logger.debug('rescale finished');
}
}
});

View File

@ -4,7 +4,6 @@ import {
IEncodeFeature,
ILayer,
ILayerPlugin,
ILogService,
IStyleAttributeService,
TYPES,
} from '@antv/l7-core';
@ -16,9 +15,6 @@ import 'reflect-metadata';
*/
@injectable()
export default class RegisterStyleAttributePlugin implements ILayerPlugin {
@inject(TYPES.ILogService)
private readonly logger: ILogService;
public apply(
layer: ILayer,
{

View File

@ -1,7 +1,6 @@
import {
ILayer,
ILayerPlugin,
ILogService,
IStyleAttributeService,
TYPES,
} from '@antv/l7-core';
@ -13,9 +12,6 @@ import 'reflect-metadata';
*/
@injectable()
export default class UpdateStyleAttributePlugin implements ILayerPlugin {
@inject(TYPES.ILogService)
private readonly logger: ILogService;
public apply(
layer: ILayer,
{
@ -66,9 +62,6 @@ export default class UpdateStyleAttributePlugin implements ILayerPlugin {
attribute.featureRange.endIndex,
);
attribute.needRegenerateVertices = false;
this.logger.debug(
`regenerate vertex attributes: ${attribute.name} finished`,
);
});
}
@ -90,7 +83,6 @@ export default class UpdateStyleAttributePlugin implements ILayerPlugin {
attribute.featureRange.endIndex,
);
attribute.needRegenerateVertices = false;
this.logger.debug(`init vertex attributes: ${attribute.name} finished`);
});
}
}

View File

@ -5,7 +5,6 @@ import {
ILayer,
ILayerModel,
ILayerPlugin,
ILogService,
IModel,
IStyleAttributeService,
lazyInject,

View File

@ -4,7 +4,6 @@ import {
IEncodeFeature,
ILayer,
ILayerPlugin,
ILogService,
IModel,
IModelUniform,
IRasterParserDataItem,

View File

@ -4,7 +4,6 @@ import {
IEncodeFeature,
ILayer,
ILayerPlugin,
ILogService,
IModelUniform,
IRasterParserDataItem,
IStyleAttributeService,

View File

@ -1,6 +1,5 @@
import {
IGlobalConfigService,
ILogService,
IMapConfig,
IMapService,
IMapWrapper,
@ -9,9 +8,6 @@ import {
} from '@antv/l7-core';
import { Container } from 'inversify';
export default class BaseMapWrapper<RawMap> implements IMapWrapper {
@lazyInject(TYPES.ILogService)
protected readonly logger: ILogService;
@lazyInject(TYPES.IGlobalConfigService)
protected readonly configService: IGlobalConfigService;

View File

@ -9,7 +9,6 @@ import {
ICoordinateSystemService,
IGlobalConfigService,
ILngLat,
ILogService,
IMapConfig,
IMapService,
IMercator,
@ -65,9 +64,6 @@ export default class AMapService
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
@inject(TYPES.MapConfig)
private readonly config: Partial<IMapConfig>;
@ -362,7 +358,7 @@ export default class AMapService
};
if (!amapLoaded && !mapInstance) {
if (token === AMAP_API_KEY) {
this.logger.warn(this.configService.getSceneWarninfo('MapToken'));
console.warn(this.configService.getSceneWarninfo('MapToken'));
}
amapLoaded = true;
plugin.push('Map3D');

View File

@ -9,7 +9,6 @@ import {
ICoordinateSystemService,
IGlobalConfigService,
ILngLat,
ILogService,
IMapConfig,
IMapService,
IMercator,
@ -74,9 +73,6 @@ export default class AMapService
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
@inject(TYPES.MapConfig)
private readonly config: Partial<IMapConfig>;
@ -460,7 +456,7 @@ export default class AMapService
this.viewport = new Viewport();
if (!amapLoaded && !mapInstance) {
if (token === AMAP_API_KEY) {
this.logger.warn(this.configService.getSceneWarninfo('MapToken'));
console.warn(this.configService.getSceneWarninfo('MapToken'));
}
amapLoaded = true;
plugin.push('Map3D');

View File

@ -7,7 +7,6 @@ import {
ICoordinateSystemService,
IGlobalConfigService,
ILngLat,
ILogService,
IMapConfig,
IMapService,
IMercator,
@ -50,8 +49,6 @@ export default class L7MapService implements IMapService<Map> {
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
@inject(TYPES.ICoordinateSystemService)
private readonly coordinateSystemService: ICoordinateSystemService;

View File

@ -7,7 +7,6 @@ import {
ICoordinateSystemService,
IGlobalConfigService,
ILngLat,
ILogService,
IMapConfig,
IMapService,
IMercator,
@ -57,8 +56,6 @@ export default class MapboxService
@inject(TYPES.IGlobalConfigService)
private readonly configService: IGlobalConfigService;
@inject(TYPES.ILogService)
private readonly logger: ILogService;
@inject(TYPES.ICoordinateSystemService)
private readonly coordinateSystemService: ICoordinateSystemService;
@ -309,7 +306,7 @@ export default class MapboxService
// 判断全局 mapboxgl 对象的加载
if (!mapInstance && !window.mapboxgl) {
// 用户有时传递进来的实例是继承于 mapbox 实例化的,不一定是 mapboxgl 对象。
this.logger.error(this.configService.getSceneWarninfo('SDK'));
console.error(this.configService.getSceneWarninfo('SDK'));
}
if (
@ -318,7 +315,8 @@ export default class MapboxService
!window.mapboxgl.accessToken &&
!mapInstance // 如果用户传递了 mapInstance应该不去干预实例的 accessToken。
) {
this.logger.warn(this.configService.getSceneWarninfo('MapToken'));
console.warn(this.configService.getSceneWarninfo('MapToken'));
}
// 判断是否设置了 accessToken

View File

@ -15,14 +15,22 @@
"jsx-double"
],
"no-bitwise": false,
"no-console": [true, "log"],
"object-literal-sort-keys": false,
"no-implicit-dependencies": [true, "dev"]
"no-implicit-dependencies": [
true,
"dev"
]
},
"globals": {
"AMap": true
},
"linterOptions": {
"exclude": ["**/*.d.ts", "**/data/*.ts", "**/*.{test,story}.ts{,x}", "node_modules/**"]
"exclude": [
"**/*.d.ts",
"**/data/*.ts",
"**/*.{test,story}.ts{,x}",
"node_modules/**"
]
}
}