diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 30249b568b..179ab6d269 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -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'; diff --git a/packages/core/src/inversify.config.ts b/packages/core/src/inversify.config.ts index 93a158f0cc..f6fdc1e864 100644 --- a/packages/core/src/inversify.config.ts +++ b/packages/core/src/inversify.config.ts @@ -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(TYPES.IShaderModuleService) .to(ShaderModuleService) .inSingletonScope(); -container - .bind(TYPES.ILogService) - .to(LogService) - .inSingletonScope(); // container // .bind(TYPES.IFontService) // .to(FontService) diff --git a/packages/core/src/services/interaction/InteractionService.ts b/packages/core/src/services/interaction/InteractionService.ts index a047e197cc..b45175edaf 100644 --- a/packages/core/src/services/interaction/InteractionService.ts +++ b/packages/core/src/services/interaction/InteractionService.ts @@ -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() { diff --git a/packages/core/src/services/log/ILogService.ts b/packages/core/src/services/log/ILogService.ts deleted file mode 100644 index d3495e6366..0000000000 --- a/packages/core/src/services/log/ILogService.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface ILogService { - error(message: string): void; - warn(message: string): void; - info(message: string): void; - debug(message: string): void; -} diff --git a/packages/core/src/services/log/LogService.ts b/packages/core/src/services/log/LogService.ts deleted file mode 100644 index 50cdad7bdd..0000000000 --- a/packages/core/src/services/log/LogService.ts +++ /dev/null @@ -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)(); - } -} diff --git a/packages/core/src/services/renderer/passes/PixelPickingPass.ts b/packages/core/src/services/renderer/passes/PixelPickingPass.ts index a5f72e6c31..6623ada734 100644 --- a/packages/core/src/services/renderer/passes/PixelPickingPass.ts +++ b/packages/core/src/services/renderer/passes/PixelPickingPass.ts @@ -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 { - @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() diff --git a/packages/core/src/services/renderer/passes/TAAPass.ts b/packages/core/src/services/renderer/passes/TAAPass.ts index f4c03668f5..c07f61fa7a 100644 --- a/packages/core/src/services/renderer/passes/TAAPass.ts +++ b/packages/core/src/services/renderer/passes/TAAPass.ts @@ -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 extends BaseNormalPass< @inject(TYPES.IShaderModuleService) protected readonly shaderModuleService: IShaderModuleService; - @inject(TYPES.ILogService) - protected readonly logger: ILogService; - /** * 低差异序列 */ @@ -193,8 +189,6 @@ export default class TAAPass 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(); diff --git a/packages/core/src/services/scene/SceneService.ts b/packages/core/src/services/scene/SceneService.ts index 1650898d40..402d25fb70 100644 --- a/packages/core/src/services/scene/SceneService.ts +++ b/packages/core/src/services/scene/SceneService.ts @@ -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`); }); // TODO:init 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; } diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index e915b9b446..436e4e2aff 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -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'), diff --git a/packages/layers/src/core/BaseLayer.ts b/packages/layers/src/core/BaseLayer.ts index 71ecfa6dff..466227d758 100644 --- a/packages/layers/src/core/BaseLayer.ts +++ b/packages/layers/src/core/BaseLayer.ts @@ -19,7 +19,6 @@ import { ILayerModelInitializationOptions, ILayerPlugin, ILayerService, - ILogService, IMapService, IModel, IModelInitializationOptions, @@ -112,9 +111,6 @@ export default class BaseLayer extends EventEmitter public layerModel: ILayerModel; - @lazyInject(TYPES.ILogService) - protected readonly logger: ILogService; - @lazyInject(TYPES.IGlobalConfigService) protected readonly configService: IGlobalConfigService; diff --git a/packages/layers/src/image/models/image.ts b/packages/layers/src/image/models/image.ts index 00ff412705..5b4f589b64 100644 --- a/packages/layers/src/image/models/image.ts +++ b/packages/layers/src/image/models/image.ts @@ -4,7 +4,6 @@ import { IEncodeFeature, ILayer, ILayerPlugin, - ILogService, IModel, IModelUniform, IRasterParserDataItem, diff --git a/packages/layers/src/plugins/DataMappingPlugin.ts b/packages/layers/src/plugins/DataMappingPlugin.ts index 67a467168c..7809c20f55 100644 --- a/packages/layers/src/plugins/DataMappingPlugin.ts +++ b/packages/layers/src/plugins/DataMappingPlugin.ts @@ -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); } diff --git a/packages/layers/src/plugins/FeatureScalePlugin.ts b/packages/layers/src/plugins/FeatureScalePlugin.ts index 451a44eeb1..13977d59d3 100644 --- a/packages/layers/src/plugins/FeatureScalePlugin.ts +++ b/packages/layers/src/plugins/FeatureScalePlugin.ts @@ -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'); } } }); diff --git a/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts b/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts index 1eed5727b1..c602aaf506 100644 --- a/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts +++ b/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts @@ -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, { diff --git a/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts b/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts index 16c55a6c44..acd1ca60be 100644 --- a/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts +++ b/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts @@ -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`); }); } } diff --git a/packages/layers/src/polygon/models/fill.ts b/packages/layers/src/polygon/models/fill.ts index 05140127e8..1794606e34 100644 --- a/packages/layers/src/polygon/models/fill.ts +++ b/packages/layers/src/polygon/models/fill.ts @@ -5,7 +5,6 @@ import { ILayer, ILayerModel, ILayerPlugin, - ILogService, IModel, IStyleAttributeService, lazyInject, diff --git a/packages/layers/src/raster/models/raster.ts b/packages/layers/src/raster/models/raster.ts index a7b3f66e75..366f639d60 100644 --- a/packages/layers/src/raster/models/raster.ts +++ b/packages/layers/src/raster/models/raster.ts @@ -4,7 +4,6 @@ import { IEncodeFeature, ILayer, ILayerPlugin, - ILogService, IModel, IModelUniform, IRasterParserDataItem, diff --git a/packages/layers/src/raster/raster.ts b/packages/layers/src/raster/raster.ts index 6ca2f1af79..3f1b81733e 100644 --- a/packages/layers/src/raster/raster.ts +++ b/packages/layers/src/raster/raster.ts @@ -4,7 +4,6 @@ import { IEncodeFeature, ILayer, ILayerPlugin, - ILogService, IModelUniform, IRasterParserDataItem, IStyleAttributeService, diff --git a/packages/maps/src/BaseMapWrapper.ts b/packages/maps/src/BaseMapWrapper.ts index 86661876c9..5d90c3a401 100644 --- a/packages/maps/src/BaseMapWrapper.ts +++ b/packages/maps/src/BaseMapWrapper.ts @@ -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 implements IMapWrapper { - @lazyInject(TYPES.ILogService) - protected readonly logger: ILogService; - @lazyInject(TYPES.IGlobalConfigService) protected readonly configService: IGlobalConfigService; diff --git a/packages/maps/src/amap/map.ts b/packages/maps/src/amap/map.ts index 336f0c2a38..4cc64e9a16 100644 --- a/packages/maps/src/amap/map.ts +++ b/packages/maps/src/amap/map.ts @@ -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; @@ -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'); diff --git a/packages/maps/src/amap2/map.ts b/packages/maps/src/amap2/map.ts index 308d276531..547b1914ec 100644 --- a/packages/maps/src/amap2/map.ts +++ b/packages/maps/src/amap2/map.ts @@ -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; @@ -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'); diff --git a/packages/maps/src/map/map.ts b/packages/maps/src/map/map.ts index 22293ed750..a4a195ab47 100644 --- a/packages/maps/src/map/map.ts +++ b/packages/maps/src/map/map.ts @@ -7,7 +7,6 @@ import { ICoordinateSystemService, IGlobalConfigService, ILngLat, - ILogService, IMapConfig, IMapService, IMercator, @@ -50,8 +49,6 @@ export default class L7MapService implements IMapService { @inject(TYPES.IGlobalConfigService) private readonly configService: IGlobalConfigService; - @inject(TYPES.ILogService) - private readonly logger: ILogService; @inject(TYPES.ICoordinateSystemService) private readonly coordinateSystemService: ICoordinateSystemService; diff --git a/packages/maps/src/mapbox/map.ts b/packages/maps/src/mapbox/map.ts index 95195ac1fe..84dfc1ba88 100644 --- a/packages/maps/src/mapbox/map.ts +++ b/packages/maps/src/mapbox/map.ts @@ -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 diff --git a/tslint.json b/tslint.json index 1040d2eb16..157a1eb4a7 100644 --- a/tslint.json +++ b/tslint.json @@ -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/**" + ] } - }