From 86aaf4d9aec4032dc4dbbee9d5b1a47a99b8ff21 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 28 Jun 2023 16:01:30 +0800 Subject: [PATCH 1/2] fix use cocos log instead --- cocos/2d/assembler/label/bmfontUtils.ts | 4 ++-- cocos/2d/assembler/sprite/tiled.ts | 4 ++-- cocos/2d/components/mask.ts | 4 ++-- cocos/2d/components/ui-mesh-renderer.ts | 4 ++-- cocos/2d/utils/dynamic-atlas/atlas.ts | 4 ++-- cocos/3d/lod/lodgroup-component.ts | 12 ++++++------ cocos/3d/misc/batch-utils.ts | 8 ++++---- .../reflection-probe-component.ts | 4 ++-- cocos/3d/skeletal-animation/limits.ts | 1 - .../skeletal-animation-blending.ts | 3 +-- .../skeletal-animation-utils.ts | 3 +-- .../3d/skeletal-animation/skeletal-animation.ts | 4 ++-- .../skinned-mesh-batch-renderer.ts | 11 +++++------ cocos/asset/asset-manager/editor-path-replace.ts | 6 +++--- cocos/asset/asset-manager/parser.ts | 8 ++++---- cocos/asset/asset-manager/utilities.ts | 2 +- cocos/asset/assets/image-asset.ts | 4 ++-- cocos/asset/assets/material.ts | 12 ++++++------ cocos/audio/audio-source.ts | 16 +++++++++------- cocos/core/algorithm/binary-search.ts | 2 +- cocos/core/curves/bezier.ts | 4 +--- cocos/core/data/custom-serializable.ts | 8 ++++---- 22 files changed, 62 insertions(+), 66 deletions(-) diff --git a/cocos/2d/assembler/label/bmfontUtils.ts b/cocos/2d/assembler/label/bmfontUtils.ts index 09735a7d9b3..6fc9630bae9 100644 --- a/cocos/2d/assembler/label/bmfontUtils.ts +++ b/cocos/2d/assembler/label/bmfontUtils.ts @@ -25,7 +25,7 @@ import { JSB } from 'internal:constants'; import { IConfig, FontAtlas } from '../../assets/bitmap-font'; import { SpriteFrame } from '../../assets/sprite-frame'; -import { Rect } from '../../../core'; +import { Rect, error } from '../../../core'; import { Label, Overflow, CacheMode } from '../../components/label'; import { UITransform } from '../../framework/ui-transform'; import { LetterAtlas, shareLabelInfo } from './font-utils'; @@ -282,7 +282,7 @@ export const bmfontUtils = { createQuadIndices (indexCount): void { if (indexCount % 6 !== 0) { - console.error('illegal index count!'); + error('illegal index count!'); return; } const quadCount = indexCount / 6; diff --git a/cocos/2d/assembler/sprite/tiled.ts b/cocos/2d/assembler/sprite/tiled.ts index 502ebb5fe4f..36e1a345a5c 100644 --- a/cocos/2d/assembler/sprite/tiled.ts +++ b/cocos/2d/assembler/sprite/tiled.ts @@ -24,7 +24,7 @@ import { JSB } from 'internal:constants'; import { IUV, SpriteFrame } from '../../assets/sprite-frame'; -import { Mat4, Vec3, Color } from '../../../core'; +import { Mat4, Vec3, Color, error } from '../../../core'; import { IRenderData, RenderData } from '../../renderer/render-data'; import { IBatcher } from '../../renderer/i-batcher'; import { Sprite } from '../../components/sprite'; @@ -121,7 +121,7 @@ export const tiled: IAssembler = { createQuadIndices (indexCount) { if (indexCount % 6 !== 0) { - console.error('illegal index count!'); + error('illegal index count!'); return; } const quadCount = indexCount / 6; diff --git a/cocos/2d/components/mask.ts b/cocos/2d/components/mask.ts index afaf7dfb44a..7c67d65ab01 100644 --- a/cocos/2d/components/mask.ts +++ b/cocos/2d/components/mask.ts @@ -25,7 +25,7 @@ import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, visible, serializable, range, slide, executeInEditMode } from 'cc.decorator'; import { JSB } from 'internal:constants'; -import { clamp, Color, Mat4, Vec2, Vec3, warnID, cclegacy, ccenum } from '../../core'; +import { clamp, Color, Mat4, Vec2, Vec3, warnID, cclegacy, ccenum, error } from '../../core'; import { Graphics } from './graphics'; import { TransformBit } from '../../scene-graph/node-enum'; import { Stage } from '../renderer/stencil-manager'; @@ -224,7 +224,7 @@ export class Mask extends Component { if (this._sprite) { this._sprite.spriteFrame = value; } else { - console.error('please change type to sprite_stencil first'); + error('please change type to sprite_stencil first'); } } diff --git a/cocos/2d/components/ui-mesh-renderer.ts b/cocos/2d/components/ui-mesh-renderer.ts index 9542a49abbd..b95ef20a3d5 100644 --- a/cocos/2d/components/ui-mesh-renderer.ts +++ b/cocos/2d/components/ui-mesh-renderer.ts @@ -34,7 +34,7 @@ import { NativeUIModelProxy } from '../renderer/native-2d'; import { uiRendererManager } from '../framework/ui-renderer-manager'; import { RenderEntity, RenderEntityType } from '../renderer/render-entity'; import { MeshRenderData, RenderData } from '../renderer/render-data'; -import { assert, cclegacy } from '../../core'; +import { assert, cclegacy, warn } from '../../core'; import { RenderDrawInfoType } from '../renderer/render-draw-info'; import type { UIRenderer } from '../framework/ui-renderer'; @@ -99,7 +99,7 @@ export class UIMeshRenderer extends Component { this._modelComponent = this.getComponent('cc.ModelRenderer') as ModelRenderer; if (!this._modelComponent) { - console.warn(`node '${this.node && this.node.name}' doesn't have any renderable component`); + warn(`node '${this.node && this.node.name}' doesn't have any renderable component`); return; } if (JSB) { diff --git a/cocos/2d/utils/dynamic-atlas/atlas.ts b/cocos/2d/utils/dynamic-atlas/atlas.ts index cb1deade823..7f1a2de9bd2 100644 --- a/cocos/2d/utils/dynamic-atlas/atlas.ts +++ b/cocos/2d/utils/dynamic-atlas/atlas.ts @@ -26,7 +26,7 @@ import { PixelFormat } from '../../../asset/assets/asset-enum'; import { ImageAsset } from '../../../asset/assets/image-asset'; import { Texture2D } from '../../../asset/assets/texture-2d'; import { BufferTextureCopy } from '../../../gfx'; -import { cclegacy } from '../../../core'; +import { cclegacy, warn } from '../../../core'; import { SpriteFrame } from '../../assets/sprite-frame'; const space = 2; @@ -254,7 +254,7 @@ export class DynamicAtlasTexture extends Texture2D { const gfxDevice = this._getGFXDevice(); if (!gfxDevice) { - console.warn('Unable to get device'); + warn('Unable to get device'); return; } diff --git a/cocos/3d/lod/lodgroup-component.ts b/cocos/3d/lod/lodgroup-component.ts index 81aa29c3258..c90823beb5a 100644 --- a/cocos/3d/lod/lodgroup-component.ts +++ b/cocos/3d/lod/lodgroup-component.ts @@ -23,7 +23,7 @@ */ import { EDITOR, JSB } from 'internal:constants'; import { ccclass, editable, executeInEditMode, menu, serializable, type } from 'cc.decorator'; -import { Vec3, Mat4, geometry, CCInteger, CCFloat } from '../../core'; +import { Vec3, Mat4, geometry, CCInteger, CCFloat, error, warn } from '../../core'; import { Node } from '../../scene-graph/node'; import { Component } from '../../scene-graph/component'; import { MeshRenderer } from '../framework/mesh-renderer'; @@ -205,7 +205,7 @@ export class LOD { */ public setRenderer (index: number, renderer: MeshRenderer): void { if (index < 0 || index >= this.rendererCount) { - console.error('setRenderer to LOD error, index out of range'); + error('setRenderer to LOD error, index out of range'); return; } this.deleteRenderer(index); @@ -378,12 +378,12 @@ export class LODGroup extends Component { */ public eraseLOD (index: number): LOD | null { if (index < 0 || index >= this.lodCount) { - console.warn('eraseLOD error, index out of range'); + warn('eraseLOD error, index out of range'); return null; } const lod = this._LODs[index]; if (!lod) { - console.warn('eraseLOD error, LOD not exist at specified index.'); + warn('eraseLOD error, LOD not exist at specified index.'); return null; } this._LODs.splice(index, 1); @@ -401,7 +401,7 @@ export class LODGroup extends Component { */ public getLOD (index: number): LOD | null { if (index < 0 || index >= this.lodCount) { - console.warn('getLOD error, index out of range'); + warn('getLOD error, index out of range'); return null; } return this._LODs[index]; @@ -415,7 +415,7 @@ export class LODGroup extends Component { */ public setLOD (index: number, lod: LOD): void { if (index < 0 || index >= this.lodCount) { - console.warn('setLOD error, index out of range'); + warn('setLOD error, index out of range'); return; } this._LODs[index] = lod; diff --git a/cocos/3d/misc/batch-utils.ts b/cocos/3d/misc/batch-utils.ts index 379a90aa273..0c0d0af9bdb 100644 --- a/cocos/3d/misc/batch-utils.ts +++ b/cocos/3d/misc/batch-utils.ts @@ -24,7 +24,7 @@ import { MeshRenderer } from '../framework/mesh-renderer'; import { Mesh } from '../assets/mesh'; -import { Mat4 } from '../../core'; +import { Mat4, error } from '../../core'; import { Node } from '../../scene-graph/node'; function checkMaterialisSame (comp1: MeshRenderer, comp2: MeshRenderer): boolean { @@ -65,16 +65,16 @@ export class BatchingUtility { public static batchStaticModel (staticModelRoot: Node, batchedRoot: Node): boolean { const models = staticModelRoot.getComponentsInChildren(MeshRenderer); if (models.length < 2) { - console.error('the number of static models to batch is less than 2,it needn\'t batch.'); + error('the number of static models to batch is less than 2,it needn\'t batch.'); return false; } for (let i = 1; i < models.length; i++) { if (!models[0].mesh!.validateMergingMesh(models[i].mesh!)) { - console.error(`the meshes of ${models[0].node.name} and ${models[i].node.name} can't be merged`); + error(`the meshes of ${models[0].node.name} and ${models[i].node.name} can't be merged`); return false; } if (!checkMaterialisSame(models[0], models[i])) { - console.error(`the materials of ${models[0].node.name} and ${models[i].node.name} can't be merged`); + error(`the materials of ${models[0].node.name} and ${models[i].node.name} can't be merged`); return false; } } diff --git a/cocos/3d/reflection-probe/reflection-probe-component.ts b/cocos/3d/reflection-probe/reflection-probe-component.ts index ec66ef564b2..5578130661e 100644 --- a/cocos/3d/reflection-probe/reflection-probe-component.ts +++ b/cocos/3d/reflection-probe/reflection-probe-component.ts @@ -23,7 +23,7 @@ */ import { ccclass, executeInEditMode, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator'; import { EDITOR, EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; -import { CCBoolean, CCObject, Color, Enum, Vec3 } from '../../core'; +import { CCBoolean, CCObject, Color, Enum, Vec3, warn } from '../../core'; import { TextureCube } from '../../asset/assets'; import { scene } from '../../render-scene'; @@ -151,7 +151,7 @@ export class ReflectionProbe extends Component { this._objFlags ^= CCObject.Flags.IsRotationLocked; } if (!this._sourceCamera) { - console.warn('the reflection camera is invalid, please set the reflection camera'); + warn('the reflection camera is invalid, please set the reflection camera'); } else { this.probe.switchProbeType(value, this._sourceCamera.camera); } diff --git a/cocos/3d/skeletal-animation/limits.ts b/cocos/3d/skeletal-animation/limits.ts index 04c066a2492..d7aa553bd01 100644 --- a/cocos/3d/skeletal-animation/limits.ts +++ b/cocos/3d/skeletal-animation/limits.ts @@ -22,5 +22,4 @@ THE SOFTWARE. */ - export const MAX_ANIMATION_LAYER = 32; diff --git a/cocos/3d/skeletal-animation/skeletal-animation-blending.ts b/cocos/3d/skeletal-animation/skeletal-animation-blending.ts index 89151362004..b1f0f167209 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation-blending.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation-blending.ts @@ -53,8 +53,7 @@ export abstract class BlendStateBuffer< this.deRef(internal.node, internal.property); } - public ref

(node: Node, property: P): PropertyBlendStateTypeMap, PropertyBlendState>[P] - { + public ref

(node: Node, property: P): PropertyBlendStateTypeMap, PropertyBlendState>[P] { let nodeBlendState = this._nodeBlendStates.get(node); if (!nodeBlendState) { nodeBlendState = this.createNodeBlendState(); diff --git a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts index 88dff5312f4..ff757cc2a82 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts @@ -381,8 +381,7 @@ export class JointTexturePool { } } - private _createAnimInfos (skeleton: Skeleton, clip: AnimationClip, skinningRoot: Node): IInternalJointAnimInfo[] - { + private _createAnimInfos (skeleton: Skeleton, clip: AnimationClip, skinningRoot: Node): IInternalJointAnimInfo[] { const animInfos: IInternalJointAnimInfo[] = []; const { joints, bindposes } = skeleton; const jointCount = joints.length; diff --git a/cocos/3d/skeletal-animation/skeletal-animation.ts b/cocos/3d/skeletal-animation/skeletal-animation.ts index 62f980eb51c..71abf07a71d 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation.ts @@ -26,7 +26,7 @@ import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable, } from 'cc.decorator'; import { SkinnedMeshRenderer } from '../skinned-mesh-renderer'; -import { Mat4, cclegacy, js, assertIsTrue } from '../../core'; +import { Mat4, cclegacy, js, assertIsTrue, warn } from '../../core'; import { DataPoolManager } from './data-pool-manager'; import { Node } from '../../scene-graph/node'; import { AnimationClip } from '../../animation/animation-clip'; @@ -276,7 +276,7 @@ export class SkeletalAnimation extends Animation { const socket = this._sockets.find((s) => s.path === path); if (socket) { return socket.target; } const joint = this.node.getChildByPath(path); - if (!joint) { console.warn('illegal socket path'); return null; } + if (!joint) { warn('illegal socket path'); return null; } const target = new Node(); target.parent = this.node; this._sockets.push(new Socket(path, target)); diff --git a/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts b/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts index 78d86ac86b2..1ea458664e6 100644 --- a/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts +++ b/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts @@ -32,7 +32,7 @@ import { Material } from '../../asset/assets/material'; import { Mesh } from '../assets/mesh'; import { Skeleton } from '../assets/skeleton'; import { Texture2D } from '../../asset/assets/texture-2d'; -import { CCString, Mat4, Vec2, Vec3, cclegacy } from '../../core'; +import { CCString, Mat4, Vec2, Vec3, cclegacy, warn } from '../../core'; import { AttributeName, FormatInfos, Format, Type, Attribute, BufferTextureCopy } from '../../gfx'; import { mapBuffer, readBuffer, writeBuffer } from '../misc/buffer'; import { SkinnedMeshRenderer } from './skinned-mesh-renderer'; @@ -118,8 +118,7 @@ export class SkinnedMeshUnit { if (comp.skinningRoot) { getWorldTransformUntilRoot(comp.node, comp.skinningRoot, this._localTransform); } } - get copyFrom (): SkinnedMeshRenderer | null - { + get copyFrom (): SkinnedMeshRenderer | null { return null; } } @@ -228,7 +227,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer { } const mat = this.getMaterialInstance(0); if (!mat || !this._batchMaterial || !this._batchMaterial.effectAsset) { - console.warn('incomplete batch material!'); return; + warn('incomplete batch material!'); return; } mat.copy(this._batchMaterial); this.resizeAtlases(); const tech = mat.effectAsset!.techniques[mat.technique]; @@ -260,7 +259,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer { } public cookSkeletons (): void { - if (!this._skinningRoot) { console.warn('no skinning root specified!'); return; } + if (!this._skinningRoot) { warn('no skinning root specified!'); return; } // merge joints accordingly const joints: string[] = []; const bindposes: Mat4[] = []; @@ -276,7 +275,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer { if (EDITOR) { // consistency check Mat4.multiply(m4_1, partial.bindposes[i], m4_local); if (!m4_1.equals(bindposes[idx])) { - console.warn(`${this.node.name}: Inconsistent bindpose at ${joints[idx]} in unit ${u}, artifacts may present`); + warn(`${this.node.name}: Inconsistent bindpose at ${joints[idx]} in unit ${u}, artifacts may present`); } } continue; diff --git a/cocos/asset/asset-manager/editor-path-replace.ts b/cocos/asset/asset-manager/editor-path-replace.ts index 970b855315a..c841daaa7ce 100644 --- a/cocos/asset/asset-manager/editor-path-replace.ts +++ b/cocos/asset/asset-manager/editor-path-replace.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ import { EDITOR, NATIVE, PREVIEW, TEST } from 'internal:constants'; -import { assert, Settings, settings } from '../../core'; +import { assert, error, Settings, settings } from '../../core'; import { fetchPipeline, pipeline } from './shared'; import Task from './task'; @@ -98,8 +98,8 @@ if ((EDITOR || PREVIEW) && !TEST) { resolveMap[uuid] = []; } return text; - } catch (error) { - console.error(error); + } catch (err) { + error(err); cache[uuid] = ''; return ''; } diff --git a/cocos/asset/asset-manager/parser.ts b/cocos/asset/asset-manager/parser.ts index 5a156500e95..0ec8d9061ec 100644 --- a/cocos/asset/asset-manager/parser.ts +++ b/cocos/asset/asset-manager/parser.ts @@ -23,7 +23,7 @@ */ import { ImageAsset, IMemoryImageSource } from '../assets/image-asset'; -import { js } from '../../core'; +import { js, warn } from '../../core'; import Cache from './cache'; import deserialize from './deserialize'; import { isScene } from './helper'; @@ -102,7 +102,7 @@ export class Parser { out = ImageAsset.parseCompressedTextures(file, 0); } catch (e) { err = e as Error; - console.warn(err); + warn(err); } onComplete(err, out); } @@ -117,7 +117,7 @@ export class Parser { out = ImageAsset.parseCompressedTextures(file, 1); } catch (e) { err = e as Error; - console.warn(err); + warn(err); } onComplete(err, out); } @@ -132,7 +132,7 @@ export class Parser { out = ImageAsset.parseCompressedTextures(file, 2); } catch (e) { err = e as Error; - console.warn(err); + warn(err); } onComplete(err, out); } diff --git a/cocos/asset/asset-manager/utilities.ts b/cocos/asset/asset-manager/utilities.ts index 11196aa66d8..4db5fe5d185 100644 --- a/cocos/asset/asset-manager/utilities.ts +++ b/cocos/asset/asset-manager/utilities.ts @@ -164,7 +164,7 @@ export function setProperties (uuid: string, asset: Asset, assetsMap: Record= this._passes.length) { console.warn(`illegal pass index: ${passIdx}.`); return; } + if (passIdx >= this._passes.length) { warn(`illegal pass index: ${passIdx}.`); return; } const pass = this._passes[passIdx]; if (this._uploadProperty(pass, name, val)) { this._props[pass.propertyIndex][name] = val; @@ -320,7 +320,7 @@ export class Material extends Asset { } } if (!success) { - console.warn(`illegal property name: ${name}.`); + warn(`illegal property name: ${name}.`); } } @@ -348,7 +348,7 @@ export class Material extends Asset { if (name in props) { return props[name]; } } } else { - if (passIdx >= this._passes.length) { console.warn(`illegal pass index: ${passIdx}.`); return null; } + if (passIdx >= this._passes.length) { warn(`illegal pass index: ${passIdx}.`); return null; } const props = this._props[this._passes[passIdx].propertyIndex]; if (name in props) { return props[name]; } } diff --git a/cocos/audio/audio-source.ts b/cocos/audio/audio-source.ts index 7f966341c8b..9eb14ff6456 100644 --- a/cocos/audio/audio-source.ts +++ b/cocos/audio/audio-source.ts @@ -26,7 +26,7 @@ import { AudioPlayer } from 'pal/audio'; import { ccclass, help, menu, tooltip, type, range, serializable } from 'cc.decorator'; import { AudioPCMDataView, AudioState } from '../../pal/audio/type'; import { Component } from '../scene-graph/component'; -import { clamp } from '../core'; +import { clamp, error, warn } from '../core'; import { AudioClip } from './audio-clip'; import { audioManager } from './audio-manager'; import { Node } from '../scene-graph'; @@ -114,7 +114,7 @@ export class AudioSource extends Component { return; } if (!clip._nativeAsset) { - console.error('Invalid audio clip'); + error('Invalid audio clip'); return; } // The state of _isloaded cannot be modified if clip is the wrong argument. @@ -161,7 +161,9 @@ export class AudioSource extends Component { @tooltip('i18n:audio.loop') set loop (val) { this._loop = val; - this._player && (this._player.loop = val); + if (this._player) { + this._player.loop = val; + } } get loop (): boolean { return this._loop; @@ -197,7 +199,7 @@ export class AudioSource extends Component { @range([0.0, 1.0]) @tooltip('i18n:audio.volume') set volume (val) { - if (Number.isNaN(val)) { console.warn('illegal audio volume!'); return; } + if (Number.isNaN(val)) { warn('illegal audio volume!'); return; } val = clamp(val, 0, 1); if (this._player) { this._player.volume = val; @@ -259,7 +261,7 @@ export class AudioSource extends Component { public getPCMData (channelIndex: number): Promise { return new Promise((resolve) => { if (channelIndex !== 0 && channelIndex !== 1) { - console.warn('Only support channel index 0 or 1 to get buffer'); + warn('Only support channel index 0 or 1 to get buffer'); resolve(undefined); return; } @@ -388,7 +390,7 @@ export class AudioSource extends Component { */ public playOneShot (clip: AudioClip, volumeScale = 1): void { if (!clip._nativeAsset) { - console.error('Invalid audio clip'); + error('Invalid audio clip'); return; } AudioPlayer.loadOneShotAudio(clip._nativeAsset.url, this._volume * volumeScale, { @@ -425,7 +427,7 @@ export class AudioSource extends Component { * @param num playback time to jump to. */ set currentTime (num: number) { - if (Number.isNaN(num)) { console.warn('illegal audio time!'); return; } + if (Number.isNaN(num)) { warn('illegal audio time!'); return; } num = clamp(num, 0, this.duration); this._cachedCurrentTime = num; this._player?.seek(this._cachedCurrentTime).catch((e): void => {}); diff --git a/cocos/core/algorithm/binary-search.ts b/cocos/core/algorithm/binary-search.ts index b39f1e61fd2..d20fa146b66 100644 --- a/cocos/core/algorithm/binary-search.ts +++ b/cocos/core/algorithm/binary-search.ts @@ -67,7 +67,7 @@ export function binarySearchEpsilon (array: Readonly>, value: * Searches the **ascending sorted** array for an element and returns the index of that element. * @param array The array to search in. * @param value The value to search. - * @param lessThan Comparison function object which returns ​true if the first argument is less than the second. + * @param lessThan Comparison function object which returns true if the first argument is less than the second. * @returns The index of the searched element in the sorted array, if found; * otherwise, returns the complement of the index of the next element greater than the searching element or, * returns the complement of array's length if no element is greater than the searching element or the array is empty. diff --git a/cocos/core/curves/bezier.ts b/cocos/core/curves/bezier.ts index 8aebb3dec68..5c2144503ba 100644 --- a/cocos/core/curves/bezier.ts +++ b/cocos/core/curves/bezier.ts @@ -144,9 +144,7 @@ function cardano (curve: BezierControlPoints, x: number): any { } else { return x2; } - } - // one real root, and two imaginary roots - else { + } else { // one real root, and two imaginary roots const sd = sqrt(discriminant); u1 = crt(-q2 + sd); v1 = crt(q2 + sd); diff --git a/cocos/core/data/custom-serializable.ts b/cocos/core/data/custom-serializable.ts index 7eb64aa802a..e7ed7fa1b72 100644 --- a/cocos/core/data/custom-serializable.ts +++ b/cocos/core/data/custom-serializable.ts @@ -74,7 +74,7 @@ export interface SerializationOutput { writeSuper(): void; } -export type SerializationContext = { +export interface SerializationContext { /** * The main serializing asset or root node in the scene/prefab passed to the serialization procedure. */ @@ -87,17 +87,17 @@ export type SerializationContext = { * Customized arguments passed to serialization procedure. */ customArguments: Record; -}; +} /** * @engineInternal */ -export type DeserializationContext = { +export interface DeserializationContext { /** * True if the deserialization procedure is deserializing from CCON. */ fromCCON: boolean; -}; +} export interface CustomSerializable { [serializeTag](output: SerializationOutput, context: SerializationContext): void; From a01a28789f300dada29cff859d31c7c1484147ce Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 28 Jun 2023 17:10:22 +0800 Subject: [PATCH 2/2] use cocos log instead for more files --- cocos/2d/assembler/label/font-utils.ts | 4 +- cocos/2d/components/sprite.ts | 4 +- cocos/asset/asset-manager/asset-manager.ts | 10 +-- cocos/asset/asset-manager/bundle.ts | 12 ++-- cocos/asset/asset-manager/cache.ts | 2 +- cocos/asset/asset-manager/downloader.ts | 4 +- cocos/asset/asset-manager/pack-manager.ts | 6 +- cocos/asset/asset-manager/parser.ts | 2 +- cocos/asset/asset-manager/pipeline.ts | 4 +- cocos/asset/asset-manager/task.ts | 4 +- cocos/asset/assets/image-asset.jsb.ts | 3 +- cocos/asset/assets/material.ts | 2 +- cocos/asset/assets/texture-cube.ts | 4 +- cocos/audio/audio-source.ts | 2 +- cocos/core/curves/gradient.ts | 2 +- cocos/core/event/async-delegate.ts | 2 +- cocos/core/event/eventify.ts | 2 +- cocos/core/geometry/deprecated-3.0.0.ts | 3 +- cocos/core/geometry/geometry-native-ext.ts | 11 +-- cocos/core/math/deprecated.ts | 2 +- cocos/core/math/vec2.ts | 5 +- cocos/core/math/vec4.ts | 5 +- cocos/core/platform/screen.ts | 4 +- cocos/core/settings.ts | 6 +- cocos/core/utils/internal.ts | 32 ++++----- cocos/core/utils/js-typed.ts | 6 +- cocos/core/utils/jsb-utils.ts | 6 +- cocos/core/utils/x-deprecated.ts | 2 +- cocos/dragon-bones/ArmatureDisplay.ts | 10 +-- cocos/dragon-bones/CCArmatureDisplay.ts | 8 +-- cocos/dragon-bones/CCSlot.ts | 4 +- cocos/dragon-bones/DragonBonesAsset.ts | 4 +- cocos/game/director.ts | 14 +++- cocos/game/game.ts | 2 +- cocos/gfx/webgl/webgl-buffer.ts | 5 +- cocos/gfx/webgl/webgl-command-buffer.ts | 7 +- cocos/gfx/webgl/webgl-commands.ts | 52 +++++++------- cocos/gfx/webgl/webgl-device.ts | 4 +- cocos/gfx/webgl/webgl-input-assembler.ts | 5 +- .../gfx/webgl/webgl-primary-command-buffer.ts | 7 +- cocos/gfx/webgl2/webgl2-buffer.ts | 5 +- cocos/gfx/webgl2/webgl2-command-buffer.ts | 7 +- cocos/gfx/webgl2/webgl2-device.ts | 4 +- cocos/gfx/webgl2/webgl2-input-assembler.ts | 5 +- .../webgl2/webgl2-primary-command-buffer.ts | 7 +- cocos/gfx/webgl2/webgl2-texture.ts | 5 +- cocos/input/input.ts | 6 +- cocos/misc/renderer.ts | 4 +- cocos/particle-2d/tiff-reader.ts | 4 +- cocos/particle/animator/texture-animation.ts | 10 +-- cocos/particle/emitter/shape-module.ts | 12 ++-- cocos/particle/particle-system.ts | 2 +- .../renderer/particle-system-renderer-cpu.ts | 4 +- .../renderer/particle-system-renderer-gpu.ts | 4 +- cocos/particle/renderer/trail.ts | 4 +- .../box2d/shapes/polygon-shape-2d.ts | 4 +- .../physics-2d/framework/physics-selector.ts | 8 +-- .../framework/utils/polygon-partition.ts | 4 +- cocos/physics/bullet/instantiated.ts | 4 +- cocos/physics/framework/physics-selector.ts | 10 +-- cocos/physics/framework/physics-system.ts | 4 +- cocos/physics/physx/physx-adapter.ts | 28 ++++---- cocos/render-scene/core/memory-pools.ts | 9 +-- cocos/render-scene/core/pass.jsb.ts | 7 +- cocos/render-scene/core/program-lib.ts | 8 +-- cocos/render-scene/core/program-utils.ts | 5 +- cocos/render-scene/utils.ts | 3 +- cocos/rendering/custom/layout-graph-utils.ts | 72 +++++++++---------- cocos/rendering/custom/web-program-library.ts | 50 ++++++------- cocos/rendering/deferred/deferred-pipeline.ts | 4 +- cocos/rendering/forward/forward-pipeline.ts | 4 +- cocos/scene-graph/layers.ts | 12 ++-- cocos/scene-graph/node-activator.ts | 4 +- cocos/scene-graph/node-dev.ts | 8 +-- cocos/scene-graph/node.ts | 4 +- cocos/serialization/instantiate-jit.ts | 2 +- cocos/tiledmap/tiled-map.ts | 4 +- cocos/tiledmap/tmx-xml-parser.ts | 10 +-- cocos/tween/tween.ts | 4 +- cocos/webgpu/instantiated.ts | 3 +- 80 files changed, 331 insertions(+), 300 deletions(-) diff --git a/cocos/2d/assembler/label/font-utils.ts b/cocos/2d/assembler/label/font-utils.ts index caa946b3a3a..464bcb66ea2 100644 --- a/cocos/2d/assembler/label/font-utils.ts +++ b/cocos/2d/assembler/label/font-utils.ts @@ -23,7 +23,7 @@ */ import { FontAtlas } from '../../assets/bitmap-font'; -import { Color, macro, warnID } from '../../../core'; +import { Color, macro, warn, warnID } from '../../../core'; import { ImageAsset, Texture2D } from '../../../asset/assets'; import { PixelFormat } from '../../../asset/assets/asset-enum'; import { BufferTextureCopy } from '../../../gfx'; @@ -251,7 +251,7 @@ export class LetterRenderTexture extends Texture2D { const gfxDevice = this._getGFXDevice(); if (!gfxDevice) { - console.warn('Unable to get device'); + warn('Unable to get device'); return; } diff --git a/cocos/2d/components/sprite.ts b/cocos/2d/components/sprite.ts index 4af575e7e5d..a4f311e0276 100644 --- a/cocos/2d/components/sprite.ts +++ b/cocos/2d/components/sprite.ts @@ -27,7 +27,7 @@ import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, range import { BUILD, EDITOR } from 'internal:constants'; import { SpriteAtlas } from '../assets/sprite-atlas'; import { SpriteFrame } from '../assets/sprite-frame'; -import { Vec2, cclegacy, ccenum, clamp } from '../../core'; +import { Vec2, cclegacy, ccenum, clamp, warn } from '../../core'; import { IBatcher } from '../renderer/i-batcher'; import { UIRenderer, InstanceMaterialType } from '../framework/ui-renderer'; import { PixelFormat } from '../../asset/assets/asset-enum'; @@ -526,7 +526,7 @@ export class Sprite extends UIRenderer { */ public changeSpriteFrameFromAtlas (name: string): void { if (!this._atlas) { - console.warn('SpriteAtlas is null.'); + warn('SpriteAtlas is null.'); return; } const sprite = this._atlas.getSpriteFrame(name); diff --git a/cocos/asset/asset-manager/asset-manager.ts b/cocos/asset/asset-manager/asset-manager.ts index 56455b0986a..e5ba3c91e80 100644 --- a/cocos/asset/asset-manager/asset-manager.ts +++ b/cocos/asset/asset-manager/asset-manager.ts @@ -612,9 +612,9 @@ export class AssetManager { * @zh 加载好的资源,如果加载过程出现了错误,资源将会 null。 * * @example - * assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err)); - * assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err)); - * assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => console.log(err)); + * assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => log(err)); + * assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => log(err)); + * assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => log(err)); * */ public loadRemote (url: string, options: { [k: string]: any, ext?: string } | null, onComplete?: ((err: Error | null, data: T) => void) | null): void; @@ -671,8 +671,8 @@ export class AssetManager { * @zh 加载完成的 bundle。如果加载过程中出现了错误,则为 null。 * * @example - * loadBundle('myBundle', (err, bundle) => console.log(bundle)); - * loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err)); + * loadBundle('myBundle', (err, bundle) => log(bundle)); + * loadBundle('http://localhost:8080/test', null, (err, bundle) => log(err)); * */ public loadBundle (nameOrUrl: string, options: { [k: string]: any, version?: string } | null, onComplete?: ((err: Error | null, data: Bundle) => void) | null): void; diff --git a/cocos/asset/asset-manager/bundle.ts b/cocos/asset/asset-manager/bundle.ts index 149adc0e376..46fc4c4bab8 100644 --- a/cocos/asset/asset-manager/bundle.ts +++ b/cocos/asset/asset-manager/bundle.ts @@ -209,16 +209,16 @@ export default class Bundle { * * @example * // load the texture (${project}/assets/resources/textures/background.jpg) from resources - * resources.load('textures/background', Texture2D, (err, texture) => console.log(err)); + * resources.load('textures/background', Texture2D, (err, texture) => log(err)); * * // load the audio (${project}/assets/resources/music/hit.mp3) from resources - * resources.load('music/hit', AudioClip, (err, audio) => console.log(err)); + * resources.load('music/hit', AudioClip, (err, audio) => log(err)); * * // load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder - * bundle1.load('misc/character/cocos', Prefab, (err, prefab) => console.log(err)); + * bundle1.load('misc/character/cocos', Prefab, (err, prefab) => log(err)); * * // load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder - * bundle2.load('imgs/cocos', SpriteFrame, null, (err, spriteFrame) => console.log(err)); + * bundle2.load('imgs/cocos', SpriteFrame, null, (err, spriteFrame) => log(err)); * */ public load ( @@ -346,10 +346,10 @@ export default class Bundle { * }); * * // load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder - * bundle1.loadDir('misc/characters', Prefab, (err, prefabs) => console.log(err)); + * bundle1.loadDir('misc/characters', Prefab, (err, prefabs) => log(err)); * * // load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder - * bundle2.loadDir('skills', SpriteFrame, null, (err, spriteFrames) => console.log(err)); + * bundle2.loadDir('skills', SpriteFrame, null, (err, spriteFrames) => log(err)); * */ public loadDir (dir: string, type: Constructor | null, onProgress: ((finished: number, total: number, item: RequestItem) => void) | null, onComplete: ((err: Error | null, data: T[]) => void) | null): void; diff --git a/cocos/asset/asset-manager/cache.ts b/cocos/asset/asset-manager/cache.ts index c655aef3ff6..80489b22f94 100644 --- a/cocos/asset/asset-manager/cache.ts +++ b/cocos/asset/asset-manager/cache.ts @@ -282,7 +282,7 @@ export default class Cache implements ICache { * * @example * var cache = new Cache(); - * cache.forEach((val, key) => console.log(key)); + * cache.forEach((val, key) => log(key)); * */ public forEach (func: (val: T, key: string) => void): void { diff --git a/cocos/asset/asset-manager/downloader.ts b/cocos/asset/asset-manager/downloader.ts index d763e639e84..401d49fed58 100644 --- a/cocos/asset/asset-manager/downloader.ts +++ b/cocos/asset/asset-manager/downloader.ts @@ -394,8 +394,8 @@ export class Downloader { * @param onComplete.content @en The downloaded file. @zh 下载下来的文件内容。 * * @example - * download('http://example.com/test.tga', '.tga', { onFileProgress: (loaded, total) => console.log(loaded/total) }, - * onComplete: (err) => console.log(err)); + * download('http://example.com/test.tga', '.tga', { onFileProgress: (loaded, total) => log(loaded/total) }, + * onComplete: (err) => log(err)); */ public download (id: string, url: string, type: string, options: Record, onComplete: ((err: Error | null, data?: any | null) => void)): void { // if it is downloaded, don't download again diff --git a/cocos/asset/asset-manager/pack-manager.ts b/cocos/asset/asset-manager/pack-manager.ts index ae4275b2073..9c835fdbe4e 100644 --- a/cocos/asset/asset-manager/pack-manager.ts +++ b/cocos/asset/asset-manager/pack-manager.ts @@ -69,7 +69,7 @@ export class PackManager { * * @example * downloader.downloadFile('pack.json', { xhrResponseType: 'json'}, null, (err, file) => { - * packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); + * packManager.unpackJson(['a', 'b'], file, null, (err, data) => log(err)); * }); * */ @@ -166,7 +166,7 @@ export class PackManager { * * @example * downloader.downloadFile('pack.json', {xhrResponseType: 'json'}, null, (err, file) => { - * packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); + * packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => log(err)); * }); * */ @@ -197,7 +197,7 @@ export class PackManager { * var requestItem = AssetManager.RequestItem.create(); * requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; * requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); - * packManager.load(requestItem, null, (err, data) => console.log(err)); + * packManager.load(requestItem, null, (err, data) => log(err)); * */ public load (item: RequestItem, options: Record | null, onComplete: ((err: Error | null, data?: any | null) => void)): void { diff --git a/cocos/asset/asset-manager/parser.ts b/cocos/asset/asset-manager/parser.ts index 0ec8d9061ec..aa24ff30ef7 100644 --- a/cocos/asset/asset-manager/parser.ts +++ b/cocos/asset/asset-manager/parser.ts @@ -223,7 +223,7 @@ export class Parser { * * @example * downloader.download('test.jpg', 'test.jpg', '.jpg', {}, (err, file) => { - * parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); + * parser.parse('test.jpg', file, '.jpg', null, (err, img) => log(err)); * }); * */ diff --git a/cocos/asset/asset-manager/pipeline.ts b/cocos/asset/asset-manager/pipeline.ts index 78c19f681d1..2b743a131ab 100644 --- a/cocos/asset/asset-manager/pipeline.ts +++ b/cocos/asset/asset-manager/pipeline.ts @@ -206,7 +206,7 @@ export class Pipeline { * }]); * * var task = new Task({input: 'test'}); - * console.log(pipeline.sync(task)); + * log(pipeline.sync(task)); * */ public sync (task: Task): any { @@ -245,7 +245,7 @@ export class Pipeline { * task.output = doSomething(task.input); * done(); * }]); - * var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); + * var task = new Task({input: 'test', onComplete: (err, result) => log(result)}); * pipeline.async(task); * */ diff --git a/cocos/asset/asset-manager/task.ts b/cocos/asset/asset-manager/task.ts index e69dcce68f2..5b64b87960e 100644 --- a/cocos/asset/asset-manager/task.ts +++ b/cocos/asset/asset-manager/task.ts @@ -247,7 +247,7 @@ export default class Task { * * @example * const task = new Task(); - * task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); + * task.set({input: ['test'], onComplete: (err, result) => log(err), onProgress: (finish, total) => log(finish / total)}); * */ public set (options: ITaskOption = Object.create(null)): void { @@ -276,7 +276,7 @@ export default class Task { * * @example * const task = Task.create(); - * task.onComplete = (msg) => console.log(msg); + * task.onComplete = (msg) => log(msg); * task.dispatch('complete', 'hello world'); * */ diff --git a/cocos/asset/assets/image-asset.jsb.ts b/cocos/asset/assets/image-asset.jsb.ts index fa68d4833a7..45fbeab5e64 100644 --- a/cocos/asset/assets/image-asset.jsb.ts +++ b/cocos/asset/assets/image-asset.jsb.ts @@ -29,6 +29,7 @@ import { sys, macro, warnID, cclegacy } from '../../core'; import { patch_cc_ImageAsset } from '../../native-binding/decorators'; import './asset'; import type { ImageAsset as JsbImageAsset } from './image-asset'; +import { error } from 'console'; declare const jsb: any; @@ -181,7 +182,7 @@ imageAssetProto._syncDataToNative = function () { } else { if(!this._nativeData._data){ - console.error(`[ImageAsset] setData bad argument ${this._nativeData}`); + error(`[ImageAsset] setData bad argument ${this._nativeData}`); return; } this.setData(this._nativeData._data); diff --git a/cocos/asset/assets/material.ts b/cocos/asset/assets/material.ts index 802a984294d..3f78c3ecb41 100644 --- a/cocos/asset/assets/material.ts +++ b/cocos/asset/assets/material.ts @@ -505,7 +505,7 @@ export class Material extends Asset { } else if (val instanceof TextureBase) { const texture: Texture | null = val.getGFXTexture(); if (!texture || !texture.width || !texture.height) { - // console.warn(`material '${this._uuid}' received incomplete texture asset '${val._uuid}'`); + // warn(`material '${this._uuid}' received incomplete texture asset '${val._uuid}'`); return; } pass.bindTexture(binding, texture, index); diff --git a/cocos/asset/assets/texture-cube.ts b/cocos/asset/assets/texture-cube.ts index 7e38085de24..ddeb81fc325 100644 --- a/cocos/asset/assets/texture-cube.ts +++ b/cocos/asset/assets/texture-cube.ts @@ -29,7 +29,7 @@ import { ImageAsset } from './image-asset'; import { PresumedGFXTextureInfo, PresumedGFXTextureViewInfo, SimpleTexture } from './simple-texture'; import { ITexture2DCreateInfo, Texture2D } from './texture-2d'; import { legacyCC, ccwindow } from '../../core/global-exports'; -import { js, sys } from '../../core'; +import { error, js, sys } from '../../core'; import { OS } from '../../../pal/system-info/enum-type'; export type ITextureCubeCreateInfo = ITexture2DCreateInfo; @@ -156,7 +156,7 @@ export class TextureCube extends SimpleTexture { || front.length !== right.length || front.length !== top.length || front.length !== bottom.length) { - console.error('The number of mipmaps of each face is different.'); + error('The number of mipmaps of each face is different.'); this._setMipmapParams([]); return; } diff --git a/cocos/audio/audio-source.ts b/cocos/audio/audio-source.ts index 9eb14ff6456..1ecd72d6a48 100644 --- a/cocos/audio/audio-source.ts +++ b/cocos/audio/audio-source.ts @@ -253,7 +253,7 @@ export class AudioSource extends Component { * audioSource.getPCMData(0).then(dataView => { * if (!dataView) return; * for (let i = 0; i < dataView.length; ++i) { - * console.log('data: ' + dataView.getData(i)); + * log('data: ' + dataView.getData(i)); * } * }); * ``` diff --git a/cocos/core/curves/gradient.ts b/cocos/core/curves/gradient.ts index 9ad938e15de..a115c489933 100644 --- a/cocos/core/curves/gradient.ts +++ b/cocos/core/curves/gradient.ts @@ -205,7 +205,7 @@ export class Gradient { } else if (time > colorKeys[lastIndex].time) { Color.lerp(out, colorKeys[lastIndex].color, Color.BLACK, (time - colorKeys[lastIndex].time) / (1 - colorKeys[lastIndex].time)); } - // console.warn('something went wrong. can not get gradient color.'); + // warn('something went wrong. can not get gradient color.'); } else if (length === 1) { Color.copy(out, colorKeys[0].color); } else { diff --git a/cocos/core/event/async-delegate.ts b/cocos/core/event/async-delegate.ts index f1d31bd1567..f4834ab55ea 100644 --- a/cocos/core/event/async-delegate.ts +++ b/cocos/core/event/async-delegate.ts @@ -38,7 +38,7 @@ import { array } from '../utils/js'; * ad.add(() => { * return new Promise((resolve, reject) => { * setTimeout(() => { - * console.log('hello world'); + * log('hello world'); * resolve(); * }, 1000); * }) diff --git a/cocos/core/event/eventify.ts b/cocos/core/event/eventify.ts index 220203b228a..f9a3b0da18f 100644 --- a/cocos/core/event/eventify.ts +++ b/cocos/core/event/eventify.ts @@ -141,7 +141,7 @@ export interface IEventified { * @param base The base class * @example * ```ts - * class Base { say() { console.log('Hello!'); } } + * class Base { say() { log('Hello!'); } } * class MyClass extends Eventify(Base) { } * function (o: MyClass) { * o.say(); // Ok: Extend from `Base` diff --git a/cocos/core/geometry/deprecated-3.0.0.ts b/cocos/core/geometry/deprecated-3.0.0.ts index fd3b9a7b434..7d9a0692128 100644 --- a/cocos/core/geometry/deprecated-3.0.0.ts +++ b/cocos/core/geometry/deprecated-3.0.0.ts @@ -34,6 +34,7 @@ import { AABB } from './aabb'; import { OBB } from './obb'; import { Capsule } from './capsule'; import { Frustum } from './frustum'; +import { warn } from '../platform'; replaceProperty(intersect, 'intersect', [ { @@ -171,7 +172,7 @@ replaceProperty(intersect, 'intersect', [ ]); function deprecatedClassMessage (oldClassName: string, newClassName): void { - console.warn(`${oldClassName} is deprecated, please use ${newClassName} instead.`); + warn(`${oldClassName} is deprecated, please use ${newClassName} instead.`); } /** diff --git a/cocos/core/geometry/geometry-native-ext.ts b/cocos/core/geometry/geometry-native-ext.ts index c54f7ad8fdf..bf4ecff2732 100644 --- a/cocos/core/geometry/geometry-native-ext.ts +++ b/cocos/core/geometry/geometry-native-ext.ts @@ -30,6 +30,7 @@ import { Sphere } from './sphere'; import { AABB } from './aabb'; import { Capsule } from './capsule'; import { Frustum } from './frustum'; +import { assert, error } from '../platform'; /** * cache jsb attributes in js, reduce cross language invokations. @@ -88,8 +89,8 @@ const defineAttrFloat = (kls: Constructor, attr: string): void => { const desc: FieldDesc = (kls as any).__nativeFields__[attr]; const cacheKey = `_$_${attr}`; if (!window.oh) { - // openharmony does not support the console.assert interface at this time. - console.assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`); + // openharmony does not support the assert interface at this time. + assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`); } Object.defineProperty(kls.prototype, desc.fieldName, { configurable: true, @@ -117,12 +118,12 @@ const defineAttrInt = (kls: Constructor, attr: string): void => { // __nativeFields__ is defined in jsb_geometry_manual.cpp const desc: FieldDesc = (kls as any).__nativeFields__[attr]; if (!desc) { - console.error(`attr ${attr} not defined in class ${kls.toString()}`); + error(`attr ${attr} not defined in class ${kls.toString()}`); } const cacheKey = `_$_${attr}`; if (!window.oh) { - // openharmony does not support the console.assert interface at this time. - console.assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`); + // openharmony does not support the assert interface at this time. + assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`); } Object.defineProperty(kls.prototype, desc.fieldName, { configurable: true, diff --git a/cocos/core/math/deprecated.ts b/cocos/core/math/deprecated.ts index 8c5df205bf4..2363088469b 100644 --- a/cocos/core/math/deprecated.ts +++ b/cocos/core/math/deprecated.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ -import { removeProperty, replaceProperty } from '../utils/x-deprecated'; +import { replaceProperty } from '../utils/x-deprecated'; import { Color } from './color'; import { Mat3 } from './mat3'; import { Mat4 } from './mat4'; diff --git a/cocos/core/math/vec2.ts b/cocos/core/math/vec2.ts index b3d9aa33150..b72af613171 100644 --- a/cocos/core/math/vec2.ts +++ b/cocos/core/math/vec2.ts @@ -31,6 +31,7 @@ import { clamp, EPSILON, random } from './utils'; import { Vec3 } from './vec3'; import { legacyCC } from '../global-exports'; +import { warn } from '../platform/debug'; /** * @en Representation of 2D vectors and points. @@ -640,7 +641,7 @@ export class Vec2 extends ValueType { * @param scalar scalar number */ public multiplyScalar (scalar: number): Vec2 { - if (typeof scalar === 'object') { console.warn('should use Vec2.multiply for vector * vector operation'); } + if (typeof scalar === 'object') { warn('should use Vec2.multiply for vector * vector operation'); } this.x *= scalar; this.y *= scalar; return this; @@ -652,7 +653,7 @@ export class Vec2 extends ValueType { * @param other specified vector */ public multiply (other: Vec2): Vec2 { - if (typeof other !== 'object') { console.warn('should use Vec2.scale for vector * scalar operation'); } + if (typeof other !== 'object') { warn('should use Vec2.scale for vector * scalar operation'); } this.x *= other.x; this.y *= other.y; return this; diff --git a/cocos/core/math/vec4.ts b/cocos/core/math/vec4.ts index 6146b721fd3..315b0ec3a07 100644 --- a/cocos/core/math/vec4.ts +++ b/cocos/core/math/vec4.ts @@ -29,6 +29,7 @@ import { Mat4 } from './mat4'; import { IMat4Like, IQuatLike, IVec4Like, IColorLike } from './type-define'; import { clamp, EPSILON, random } from './utils'; import { legacyCC } from '../global-exports'; +import { warn } from '../platform/debug'; /** * @en Representation of four-dimensional vectors. @@ -774,7 +775,7 @@ export class Vec4 extends ValueType { * @param scalar scalar number */ public multiplyScalar (scalar: number): Vec4 { - if (typeof scalar === 'object') { console.warn('should use Vec4.multiply for vector * vector operation'); } + if (typeof scalar === 'object') { warn('should use Vec4.multiply for vector * vector operation'); } this.x *= scalar; this.y *= scalar; this.z *= scalar; @@ -788,7 +789,7 @@ export class Vec4 extends ValueType { * @param other specified vector */ public multiply (other: Vec4): Vec4 { - if (typeof other !== 'object') { console.warn('should use Vec4.scale for vector * scalar operation'); } + if (typeof other !== 'object') { warn('should use Vec4.scale for vector * scalar operation'); } this.x *= other.x; this.y *= other.y; this.z *= other.z; diff --git a/cocos/core/platform/screen.ts b/cocos/core/platform/screen.ts index 0cfb92be0e6..a908482eed1 100644 --- a/cocos/core/platform/screen.ts +++ b/cocos/core/platform/screen.ts @@ -29,7 +29,7 @@ import { IScreenOptions, screenAdapter } from 'pal/screen-adapter'; import { legacyCC } from '../global-exports'; import { Size } from '../math'; import { Settings, settings } from '../settings'; -import { warnID } from './debug'; +import { error, warnID } from './debug'; import { PalScreenEvent } from '../../../pal/screen-adapter/enum-type'; /** * @en The screen API provides an easy way to do some screen managing stuff. @@ -157,7 +157,7 @@ class Screen { return screenAdapter.requestFullScreen().then((): void => { onFullScreenChange?.call(document); // this case is only used on Web platforms, which is deprecated since v3.3.0 }).catch((err): void => { - console.error(err); + error(err); onFullScreenError?.call(document); // this case is only used on Web platforms, which is deprecated since v3.3.0 }); } diff --git a/cocos/core/settings.ts b/cocos/core/settings.ts index 91cd9eaa09d..5869072b989 100644 --- a/cocos/core/settings.ts +++ b/cocos/core/settings.ts @@ -137,9 +137,9 @@ export class Settings { * * @example * ```ts - * console.log(settings.querySettings(Settings.Category.ASSETS, 'server')); // print https://www.cocos.com + * log(settings.querySettings(Settings.Category.ASSETS, 'server')); // print https://www.cocos.com * settings.overrideSettings(Settings.Category.ASSETS, 'server', 'http://www.test.com'); - * console.log(settings.querySettings(Settings.Category.ASSETS, 'server')); // print http://www.test.com + * log(settings.querySettings(Settings.Category.ASSETS, 'server')); // print http://www.test.com * ``` */ overrideSettings (category: Category | string, name: string, value: T): void { @@ -162,7 +162,7 @@ export class Settings { * * @example * ```ts - * console.log(settings.querySettings(Settings.Category.ENGINE, 'debug')); // print false + * log(settings.querySettings(Settings.Category.ENGINE, 'debug')); // print false * ``` */ querySettings (category: Category | string, name: string): T | null { diff --git a/cocos/core/utils/internal.ts b/cocos/core/utils/internal.ts index 4835fdeacc0..6504a129d21 100644 --- a/cocos/core/utils/internal.ts +++ b/cocos/core/utils/internal.ts @@ -32,38 +32,38 @@ * // 成功重命名,属性顺序保留 * const original = { a: 1, b: 2, c: 3 }; * Object.defineProperty(original, 'x', { value: '', enumerable: false }); - * console.log(original); // {a: 1, b: 2, c: 3, x: ''} + * log(original); // {a: 1, b: 2, c: 3, x: ''} * * const renamed = renameObjectProperty(original, 'b', 'd'); - * console.log(original === renamed) // false - * console.log(original); // {a: 1, d: 2, c: 3} - * console.log(Object.entries(renamed)) // [['a', 1], ['d', 2], ['c', 3]] + * log(original === renamed) // false + * log(original); // {a: 1, d: 2, c: 3} + * log(Object.entries(renamed)) // [['a', 1], ['d', 2], ['c', 3]] * * // 重命名失败:原始键不存在 - * console.log(renameObjectProperty(original, 'e', 'f') === original); // true + * log(renameObjectProperty(original, 'e', 'f') === original); // true * // 重命名失败:新键已存在 - * console.log(renameObjectProperty(original, 'e', 'a') === original); // true + * log(renameObjectProperty(original, 'e', 'a') === original); // true * // 重命名失败:原始键对应的属性不是自身可枚举的 - * console.log(renameObjectProperty(original, 'x', 'x1') === original); // true + * log(renameObjectProperty(original, 'x', 'x1') === original); // true * ``` * @en * ```ts * // Rename succeed, key order is retained. * const original = { a: 1, b: 2, c: 3 }; * Object.defineProperty(original, 'x', { value: '', enumerable: false }); - * console.log(original); // {a: 1, b: 2, c: 3, x: ''} + * log(original); // {a: 1, b: 2, c: 3, x: ''} * * const renamed = renameObjectProperty(original, 'b', 'd'); - * console.log(original === renamed) // false - * console.log(original); // {a: 1, d: 2, c: 3} - * console.log(Object.entries(renamed)) // [['a', 1], ['d', 2], ['c', 3]] + * log(original === renamed) // false + * log(original); // {a: 1, d: 2, c: 3} + * log(Object.entries(renamed)) // [['a', 1], ['d', 2], ['c', 3]] * * // Rename failed: the original key does not exist. - * console.log(renameObjectProperty(original, 'e', 'f') === original); // true + * log(renameObjectProperty(original, 'e', 'f') === original); // true * // Rename failed: the new key has already existed. - * console.log(renameObjectProperty(original, 'e', 'a') === original); // true + * log(renameObjectProperty(original, 'e', 'a') === original); // true * // Rename failed: the corresponding original property is not enumerable own property. - * console.log(renameObjectProperty(original, 'x', 'x1') === original); // true + * log(renameObjectProperty(original, 'x', 'x1') === original); // true * ``` */ export function renameObjectProperty> ( @@ -141,7 +141,7 @@ export function renameObjectProperty> ( * * new FooProxy(); // 这句会抛出异常 * // 达到了我们的目的:不允许直接 `new Foo` - * console.log(createFoo() instanceof FooProxy); // 输出 "true" + * log(createFoo() instanceof FooProxy); // 输出 "true" * // 达到了我们的目的:可以使用 `instanceof` * ``` * @en @@ -162,7 +162,7 @@ export function renameObjectProperty> ( * * new FooProxy(); // This will throw * // This is what we want to achieve: `new Foo` is not allowed - * console.log(createFoo() instanceof FooProxy); // Print "true" + * log(createFoo() instanceof FooProxy); // Print "true" * // This is what we want to achieve: `instanceof` is available * ``` */ diff --git a/cocos/core/utils/js-typed.ts b/cocos/core/utils/js-typed.ts index 59d3adfb888..04e8c08b152 100644 --- a/cocos/core/utils/js-typed.ts +++ b/cocos/core/utils/js-typed.ts @@ -23,7 +23,7 @@ */ import { EDITOR, DEV, TEST } from 'internal:constants'; -import { warnID, error, errorID, StringSubstitution } from '../platform/debug'; +import { warnID, error, errorID, StringSubstitution, log } from '../platform/debug'; import { IDGenerator } from './id-generator'; const tempCIDGenerator = new IDGenerator('TmpCId.'); @@ -136,7 +136,7 @@ export const getset = ((): (object: Record, propertyName: }; return (object: Record, propertyName: string, getter: Getter, setter?: Setter | boolean, enumerable = false, configurable = false): void => { if (typeof setter === 'boolean') { - console.log('Set `setter` to boolean is deprecated. Please don not use like this again.'); + log('Set `setter` to boolean is deprecated. Please don not use like this again.'); enumerable = setter; setter = undefined; } @@ -642,7 +642,7 @@ js.unregisterClass to remove the id of unused class'; table[id] = constructor; } // if (id === "") { - // console.trace("", table === _nameToClass); + // trace("", table === _nameToClass); // } } }; diff --git a/cocos/core/utils/jsb-utils.ts b/cocos/core/utils/jsb-utils.ts index efab2acf672..af6f48d60da 100644 --- a/cocos/core/utils/jsb-utils.ts +++ b/cocos/core/utils/jsb-utils.ts @@ -60,16 +60,16 @@ import type { Node } from '../../scene-graph'; // func.apply(target, arguments); // }; // } else { -// console.error('dont go here....'); +// error(`don't go here....`); // result = target[property]; // } -// console.warn(`==> get [${property}], result: ${result}, for target: ${target}`); +// warn(`==> get [${property}], result: ${result}, for target: ${target}`); // // property is index in this case // return result; // } // // set (target: any, property: string, value: any, receiver: any) { -// console.warn(`==> set [${property}]=${value}, for target: ${target}`); +// warn(`==> set [${property}]=${value}, for target: ${target}`); // const i = parseInt(property); // if (!isNaN(i)) { // if (typeof value === this._options.arrElementType) { diff --git a/cocos/core/utils/x-deprecated.ts b/cocos/core/utils/x-deprecated.ts index e41125b347a..55021068305 100644 --- a/cocos/core/utils/x-deprecated.ts +++ b/cocos/core/utils/x-deprecated.ts @@ -381,7 +381,7 @@ let _cachedProxy; * @example * ```ts * import * as cc from 'cc'; - * console.log(cc.ButtonComponent); // print deprecate info of ButtonComponent + * log(cc.ButtonComponent); // print deprecate info of ButtonComponent * ``` * @engineInternal */ diff --git a/cocos/dragon-bones/ArmatureDisplay.ts b/cocos/dragon-bones/ArmatureDisplay.ts index 2e70e6d9660..d110d5787aa 100644 --- a/cocos/dragon-bones/ArmatureDisplay.ts +++ b/cocos/dragon-bones/ArmatureDisplay.ts @@ -25,7 +25,7 @@ import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; import { Armature, Bone, EventObject, AnimationState } from '@cocos/dragonbones-js'; import { UIRenderer } from '../2d/framework/ui-renderer'; -import { Color, Enum, ccenum, errorID, RecyclePool, js, CCObject, EventTarget, cclegacy, _decorator } from '../core'; +import { Color, Enum, ccenum, errorID, RecyclePool, js, CCObject, EventTarget, cclegacy, _decorator, warn, error } from '../core'; import { BlendFactor } from '../gfx'; import { AnimationCache, ArmatureCache, ArmatureFrame } from './ArmatureCache'; import { AttachUtil } from './AttachUtil'; @@ -354,7 +354,7 @@ export class ArmatureDisplay extends UIRenderer { if (this._defaultCacheMode !== AnimationCacheMode.REALTIME) { if (this._armature && !ArmatureCache.canCache(this._armature)) { this._defaultCacheMode = AnimationCacheMode.REALTIME; - console.warn('Animation cache mode doesn\'t support skeletal nesting'); + warn('Animation cache mode doesn\'t support skeletal nesting'); return; } } @@ -1076,7 +1076,7 @@ export class ArmatureDisplay extends UIRenderer { } if (this._cacheMode !== AnimationCacheMode.REALTIME && this.debugBones) { - console.warn('Debug bones is invalid in cached mode'); + warn('Debug bones is invalid in cached mode'); } if (this._armature) { @@ -1481,7 +1481,7 @@ export class ArmatureDisplay extends UIRenderer { if (socket.path && socket.target) { const bone = this._cachedSockets.get(socket.path); if (!bone) { - console.error(`Skeleton data does not contain path ${socket.path}`); + error(`Skeleton data does not contain path ${socket.path}`); continue; } socket.boneIndex = bone as unknown as number; @@ -1495,7 +1495,7 @@ export class ArmatureDisplay extends UIRenderer { const target = sockets[i].target; if (target) { if (!target.parent || (target.parent !== this.node)) { - console.error(`Target node ${target.name} is expected to be a direct child of ${this.node.name}`); + error(`Target node ${target.name} is expected to be a direct child of ${this.node.name}`); continue; } } diff --git a/cocos/dragon-bones/CCArmatureDisplay.ts b/cocos/dragon-bones/CCArmatureDisplay.ts index d4987a860db..4d9918f91ff 100644 --- a/cocos/dragon-bones/CCArmatureDisplay.ts +++ b/cocos/dragon-bones/CCArmatureDisplay.ts @@ -24,7 +24,7 @@ */ import { Armature, DisplayData, IEventDispatcher, Slot } from '@cocos/dragonbones-js'; -import { Vec3, EventTarget, _decorator } from '../core'; +import { Vec3, EventTarget, _decorator, warn } from '../core'; // eslint-disable-next-line import/named import { CCSlot } from './CCSlot'; import { ArmatureDisplay } from './ArmatureDisplay'; @@ -77,7 +77,7 @@ export class CCArmatureDisplay extends DisplayData implements IEventDispatcher { * @zh 方法未实现总返回 false。 */ hasEvent (type: string): boolean { - console.warn('Method not implemented.'); + warn('Method not implemented.'); return false; } /** @@ -85,14 +85,14 @@ export class CCArmatureDisplay extends DisplayData implements IEventDispatcher { * @zh 方法未实现。 */ addEvent (type: string, listener: any, thisObject: any): void { - console.warn('Method not implemented.'); + warn('Method not implemented.'); } /** * @en The funciton has no realization. * @zh 方法未实现。 */ removeEvent (type: string, listener: any, thisObject: any): void { - console.warn('Method not implemented.'); + warn('Method not implemented.'); } /** * @en Sets EventTarget object. diff --git a/cocos/dragon-bones/CCSlot.ts b/cocos/dragon-bones/CCSlot.ts index 94f905998e1..9d244949492 100644 --- a/cocos/dragon-bones/CCSlot.ts +++ b/cocos/dragon-bones/CCSlot.ts @@ -24,7 +24,7 @@ import { BoneType, BinaryOffset, Slot } from '@cocos/dragonbones-js'; import { Texture2D } from '../asset/assets'; -import { Color, Mat4, _decorator } from '../core'; +import { Color, Mat4, _decorator, error } from '../core'; import { CCTextureData } from './CCTextureData'; const { ccclass } = _decorator; @@ -235,7 +235,7 @@ export class CCSlot extends Slot { const region = currentTextureData.region; if (textureAtlasWidth === 0 || textureAtlasHeight === 0) { - console.error(`SpriteFrame ${currentTextureData.spriteFrame.name} incorrect size ${textureAtlasWidth} x ${textureAtlasHeight}`); + error(`SpriteFrame ${currentTextureData.spriteFrame.name} incorrect size ${textureAtlasWidth} x ${textureAtlasHeight}`); return; } diff --git a/cocos/dragon-bones/DragonBonesAsset.ts b/cocos/dragon-bones/DragonBonesAsset.ts index 420280ee59b..f79e8c75667 100644 --- a/cocos/dragon-bones/DragonBonesAsset.ts +++ b/cocos/dragon-bones/DragonBonesAsset.ts @@ -25,7 +25,7 @@ import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; import { Asset } from '../asset/assets'; import { ArmatureCache } from './ArmatureCache'; -import { Enum, cclegacy, _decorator } from '../core'; +import { Enum, cclegacy, _decorator, warn } from '../core'; import { CCFactory } from './CCFactory'; import { Node } from '../scene-graph'; @@ -115,7 +115,7 @@ export class DragonBonesAsset extends Asset { if (dbData) { this._uuid = dbData.name; } else { - console.warn('dragonbones name is empty'); + warn('dragonbones name is empty'); } } diff --git a/cocos/game/director.ts b/cocos/game/director.ts index 19a38b13abd..67767868813 100644 --- a/cocos/game/director.ts +++ b/cocos/game/director.ts @@ -315,14 +315,17 @@ export class Director extends EventTarget { assertID(scene instanceof Scene, 1216); if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.time('InitScene'); } scene._load(); // ensure scene initialized if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.timeEnd('InitScene'); } // Re-attach or replace persist nodes if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.time('AttachPersist'); } const persistNodeList = Object.keys(this._persistRootNodes).map((x): Node => this._persistRootNodes[x] as Node); @@ -344,12 +347,14 @@ export class Director extends EventTarget { } } if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.timeEnd('AttachPersist'); } const oldScene = this._scene; // unload scene if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.time('Destroy'); } if (isValid(oldScene)) { @@ -358,10 +363,12 @@ export class Director extends EventTarget { if (!EDITOR) { // auto release assets if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.time('AutoRelease'); } releaseManager._autoRelease(oldScene!, scene, this._persistRootNodes); if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.timeEnd('AutoRelease'); } } @@ -370,6 +377,7 @@ export class Director extends EventTarget { // purge destroyed nodes belongs to old scene CCObject._deferredDestroy(); + // eslint-disable-next-line no-console if (BUILD && DEBUG) { console.timeEnd('Destroy'); } if (onBeforeLoadScene) { @@ -385,10 +393,12 @@ export class Director extends EventTarget { this._scene = scene; if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.time('Activate'); } scene._activate(); if (BUILD && DEBUG) { + // eslint-disable-next-line no-console console.timeEnd('Activate'); } // start scene @@ -440,8 +450,10 @@ export class Director extends EventTarget { if (bundle) { this.emit(Director.EVENT_BEFORE_SCENE_LOADING, sceneName); this._loadingScene = sceneName; + // eslint-disable-next-line no-console console.time(`LoadScene ${sceneName}`); bundle.loadScene(sceneName, (err, scene): void => { + // eslint-disable-next-line no-console console.timeEnd(`LoadScene ${sceneName}`); this._loadingScene = ''; if (err) { @@ -508,7 +520,7 @@ export class Director extends EventTarget { } } - public buildGPUScene (scene: Scene) { + public buildGPUScene (scene: Scene): void { const sceneData = this.root!.pipeline.pipelineSceneData; if (!sceneData || !sceneData.isGPUDrivenEnabled()) { return; diff --git a/cocos/game/game.ts b/cocos/game/game.ts index 5f3eac8149d..3f86e7faaab 100644 --- a/cocos/game/game.ts +++ b/cocos/game/game.ts @@ -1013,7 +1013,7 @@ export class Game extends EventTarget { if (launchScene) { // load scene director.loadScene(launchScene, (): void => { - console.log(`Success to load scene: ${launchScene}`); + log(`Success to load scene: ${launchScene}`); this._initTime = performance.now(); director.startAnimation(); this.onStart?.(); diff --git a/cocos/gfx/webgl/webgl-buffer.ts b/cocos/gfx/webgl/webgl-buffer.ts index a4533b76dea..99c74ae324d 100644 --- a/cocos/gfx/webgl/webgl-buffer.ts +++ b/cocos/gfx/webgl/webgl-buffer.ts @@ -33,6 +33,7 @@ import { } from './webgl-commands'; import { IWebGLGPUBuffer, IWebGLGPUBufferView, WebGLIndirectDrawInfos } from './webgl-gpu-objects'; import { WebGLDeviceManager } from './webgl-define'; +import { warn } from '../../core'; export class WebGLBuffer extends Buffer { get gpuBuffer (): IWebGLGPUBuffer { @@ -111,7 +112,7 @@ export class WebGLBuffer extends Buffer { public resize (size: number): void { if (this._isBufferView) { - console.warn('cannot resize buffer views!'); + warn('cannot resize buffer views!'); return; } @@ -141,7 +142,7 @@ export class WebGLBuffer extends Buffer { public update (buffer: Readonly, size?: number): void { if (this._isBufferView) { - console.warn('cannot update through buffer views!'); + warn('cannot update through buffer views!'); return; } diff --git a/cocos/gfx/webgl/webgl-command-buffer.ts b/cocos/gfx/webgl/webgl-command-buffer.ts index f4868493ec3..56bd2b55038 100644 --- a/cocos/gfx/webgl/webgl-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-command-buffer.ts @@ -47,6 +47,7 @@ import { GeneralBarrier } from '../base/states/general-barrier'; import { TextureBarrier } from '../base/states/texture-barrier'; import { BufferBarrier } from '../base/states/buffer-barrier'; import { WebGLDeviceManager } from './webgl-define'; +import { error } from '../../core'; export class WebGLCommandBuffer extends CommandBuffer { public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage(); @@ -295,7 +296,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } } else { - console.error('Command \'draw\' must be recorded inside a render pass.'); + error('Command \'draw\' must be recorded inside a render pass.'); } } @@ -331,7 +332,7 @@ export class WebGLCommandBuffer extends CommandBuffer { this.cmdPackage.cmds.push(WebGLCmd.UPDATE_BUFFER); } } else { - console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); + error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -353,7 +354,7 @@ export class WebGLCommandBuffer extends CommandBuffer { } } } else { - console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); + error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } } diff --git a/cocos/gfx/webgl/webgl-commands.ts b/cocos/gfx/webgl/webgl-commands.ts index 3e9ed5d9620..75949274f00 100644 --- a/cocos/gfx/webgl/webgl-commands.ts +++ b/cocos/gfx/webgl/webgl-commands.ts @@ -179,7 +179,7 @@ export function GFXFormatToWebGLInternalFormat (format: Format, gl: WebGLRenderi case Format.DEPTH_STENCIL: return gl.DEPTH_STENCIL; default: { - console.error('Unsupported Format, convert to WebGL internal format failed.'); + error('Unsupported Format, convert to WebGL internal format failed.'); return gl.RGBA; } } @@ -261,7 +261,7 @@ export function GFXFormatToWebGLFormat (format: Format, gl: WebGLRenderingContex case Format.ASTC_SRGBA_12X12: return WebGLEXT.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; default: { - console.error('Unsupported Format, convert to WebGL format failed.'); + error('Unsupported Format, convert to WebGL format failed.'); return gl.RGBA; } } @@ -288,7 +288,7 @@ function GFXTypeToWebGLType (type: Type, gl: WebGLRenderingContext): GLenum { case Type.SAMPLER2D: return gl.SAMPLER_2D; case Type.SAMPLER_CUBE: return gl.SAMPLER_CUBE; default: { - console.error('Unsupported GLType, convert to GL type failed.'); + error('Unsupported GLType, convert to GL type failed.'); return Type.UNKNOWN; } } @@ -315,7 +315,7 @@ function GFXTypeToTypedArrayCtor (type: Type): Int32ArrayConstructor | Float32Ar case Type.MAT4: return Float32Array; default: { - console.error('Unsupported GLType, convert to TypedArrayConstructor failed.'); + error('Unsupported GLType, convert to TypedArrayConstructor failed.'); return Float32Array; } } @@ -342,7 +342,7 @@ function WebGLTypeToGFXType (glType: GLenum, gl: WebGLRenderingContext): Type { case gl.SAMPLER_2D: return Type.SAMPLER2D; case gl.SAMPLER_CUBE: return Type.SAMPLER_CUBE; default: { - console.error('Unsupported GLType, convert to Type failed.'); + error('Unsupported GLType, convert to Type failed.'); return Type.UNKNOWN; } } @@ -369,7 +369,7 @@ function WebGLGetTypeSize (glType: GLenum, gl: WebGLRenderingContext): Type { case gl.SAMPLER_2D: return 4; case gl.SAMPLER_CUBE: return 4; default: { - console.error('Unsupported GLType, get type failed.'); + error('Unsupported GLType, get type failed.'); return 0; } } @@ -665,7 +665,7 @@ export function WebGLCmdFuncCreateBuffer (device: WebGLDevice, gpuBuffer: IWebGL } else if (gpuBuffer.usage & BufferUsageBit.TRANSFER_SRC) { gpuBuffer.glTarget = gl.NONE; } else { - console.error('Unsupported BufferType, create buffer failed.'); + error('Unsupported BufferType, create buffer failed.'); gpuBuffer.glTarget = gl.NONE; } } @@ -764,7 +764,7 @@ export function WebGLCmdFuncResizeBuffer (device: WebGLDevice, gpuBuffer: IWebGL || (gpuBuffer.usage & BufferUsageBit.TRANSFER_SRC)) { gpuBuffer.glTarget = gl.NONE; } else { - console.error('Unsupported BufferType, create buffer failed.'); + error('Unsupported BufferType, create buffer failed.'); gpuBuffer.glTarget = gl.NONE; } } @@ -814,7 +814,7 @@ export function WebGLCmdFuncUpdateBuffer (device: WebGLDevice, gpuBuffer: IWebGL break; } default: { - console.error('Unsupported BufferType, update buffer failed.'); + error('Unsupported BufferType, update buffer failed.'); return; } } @@ -961,7 +961,7 @@ export function WebGLCmdFuncCreateTexture (device: WebGLDevice, gpuTexture: IWeb break; } default: { - console.error('Unsupported TextureType, create texture failed.'); + error('Unsupported TextureType, create texture failed.'); gpuTexture.type = TextureType.TEX2D; gpuTexture.glTarget = gl.TEXTURE_2D; } @@ -1088,7 +1088,7 @@ export function WebGLCmdFuncResizeTexture (device: WebGLDevice, gpuTexture: IWeb break; } default: { - console.error('Unsupported TextureType, create texture failed.'); + error('Unsupported TextureType, create texture failed.'); gpuTexture.type = TextureType.TEX2D; gpuTexture.glTarget = gl.TEXTURE_2D; } @@ -1172,19 +1172,19 @@ export function WebGLCmdFuncCreateFramebuffer (device: WebGLDevice, gpuFramebuff if (status !== gl.FRAMEBUFFER_COMPLETE) { switch (status) { case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: { - console.error('glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT'); + error('glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT'); break; } case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: { - console.error('glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT'); + error('glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT'); break; } case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: { - console.error('glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS'); + error('glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS'); break; } case gl.FRAMEBUFFER_UNSUPPORTED: { - console.error('glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED'); + error('glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED'); break; } default: @@ -1230,7 +1230,7 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL break; } default: { - console.error('Unsupported ShaderType.'); + error('Unsupported ShaderType.'); return; } } @@ -1242,9 +1242,9 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL gl.compileShader(gpuStage.glShader); if (!gl.getShaderParameter(gpuStage.glShader, gl.COMPILE_STATUS)) { - console.error(`${shaderTypeStr} in '${gpuShader.name}' compilation failed.`); - console.error('Shader source dump:', gpuStage.source.replace(/^|\n/g, (): string => `\n${lineNumber++} `)); - console.error(gl.getShaderInfoLog(gpuStage.glShader)); + error(`${shaderTypeStr} in '${gpuShader.name}' compilation failed.`); + error('Shader source dump:', gpuStage.source.replace(/^|\n/g, (): string => `\n${lineNumber++} `)); + error(gl.getShaderInfoLog(gpuStage.glShader)); for (let l = 0; l < gpuShader.gpuStages.length; l++) { const stage = gpuShader.gpuStages[k]; @@ -1288,8 +1288,8 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL if (gl.getProgramParameter(gpuShader.glProgram, gl.LINK_STATUS)) { debug(`Shader '${gpuShader.name}' compilation succeeded.`); } else { - console.error(`Failed to link shader '${gpuShader.name}'.`); - console.error(gl.getProgramInfoLog(gpuShader.glProgram)); + error(`Failed to link shader '${gpuShader.name}'.`); + error(gl.getProgramInfoLog(gpuShader.glProgram)); return; } @@ -2655,7 +2655,7 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( case gl.TEXTURE_2D: { for (let i = 0; i < regions.length; i++) { const region = regions[i]; - // console.debug('Copying image to texture 2D: ' + region.texExtent.width + ' x ' + region.texExtent.height); + // debug('Copying image to texture 2D: ' + region.texExtent.width + ' x ' + region.texExtent.height); gl.texSubImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel, region.texOffset.x, region.texOffset.y, gpuTexture.glFormat, gpuTexture.glType, texImages[n++]); @@ -2665,7 +2665,7 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( case gl.TEXTURE_CUBE_MAP: { for (let i = 0; i < regions.length; i++) { const region = regions[i]; - // console.debug('Copying image to texture cube: ' + region.texExtent.width + ' x ' + region.texExtent.height); + // debug('Copying image to texture cube: ' + region.texExtent.width + ' x ' + region.texExtent.height); const fcount = region.texSubres.baseArrayLayer + region.texSubres.layerCount; for (f = region.texSubres.baseArrayLayer; f < fcount; ++f) { gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, region.texSubres.mipLevel, @@ -2676,7 +2676,7 @@ export function WebGLCmdFuncCopyTexImagesToTexture ( break; } default: { - console.error('Unsupported GL texture type, copy buffer to texture failed.'); + error('Unsupported GL texture type, copy buffer to texture failed.'); } } @@ -2847,7 +2847,7 @@ export function WebGLCmdFuncCopyBuffersToTexture ( break; } default: { - console.error('Unsupported GL texture type, copy buffer to texture failed.'); + error('Unsupported GL texture type, copy buffer to texture failed.'); } } @@ -2886,7 +2886,7 @@ export function WebGLCmdFuncCopyTextureToBuffers ( break; } default: { - console.error('Unsupported GL texture type, copy texture to buffers failed.'); + error('Unsupported GL texture type, copy texture to buffers failed.'); } } gl.bindFramebuffer(gl.FRAMEBUFFER, null); diff --git a/cocos/gfx/webgl/webgl-device.ts b/cocos/gfx/webgl/webgl-device.ts index 6367e870c88..67b6dea3520 100644 --- a/cocos/gfx/webgl/webgl-device.ts +++ b/cocos/gfx/webgl/webgl-device.ts @@ -61,7 +61,7 @@ import { WebGLCmdFuncCopyBuffersToTexture, WebGLCmdFuncCopyTextureToBuffers, Web import { GeneralBarrier } from '../base/states/general-barrier'; import { TextureBarrier } from '../base/states/texture-barrier'; import { BufferBarrier } from '../base/states/buffer-barrier'; -import { debug } from '../../core'; +import { debug, error } from '../../core'; import { Swapchain } from '../base/swapchain'; import { IWebGLExtensions, WebGLDeviceManager } from './webgl-define'; import { IWebGLBindingMapping, IWebGLBlitManager } from './webgl-gpu-objects'; @@ -137,7 +137,7 @@ export class WebGLDevice extends Device { const gl = this._context = getContext(Device.canvas); if (!gl) { - console.error('This device does not support WebGL.'); + error('This device does not support WebGL.'); return false; } diff --git a/cocos/gfx/webgl/webgl-input-assembler.ts b/cocos/gfx/webgl/webgl-input-assembler.ts index 4208609de41..bd93e260e41 100644 --- a/cocos/gfx/webgl/webgl-input-assembler.ts +++ b/cocos/gfx/webgl/webgl-input-assembler.ts @@ -22,6 +22,7 @@ THE SOFTWARE. */ +import { error } from '../../core'; import { InputAssemblerInfo } from '../base/define'; import { InputAssembler } from '../base/input-assembler'; import { WebGLBuffer } from './webgl-buffer'; @@ -38,7 +39,7 @@ export class WebGLInputAssembler extends InputAssembler { public initialize (info: Readonly): void { if (info.vertexBuffers.length === 0) { - console.error('InputAssemblerInfo.vertexBuffers is null.'); + error('InputAssemblerInfo.vertexBuffers is null.'); return; } @@ -77,7 +78,7 @@ export class WebGLInputAssembler extends InputAssembler { case 2: glIndexType = 0x1403; break; // WebGLRenderingContext.UNSIGNED_SHORT case 4: glIndexType = 0x1405; break; // WebGLRenderingContext.UNSIGNED_INT default: { - console.error('Error index buffer stride.'); + error('Error index buffer stride.'); } } } diff --git a/cocos/gfx/webgl/webgl-primary-command-buffer.ts b/cocos/gfx/webgl/webgl-primary-command-buffer.ts index 792defd0fc7..02e6a58f95d 100644 --- a/cocos/gfx/webgl/webgl-primary-command-buffer.ts +++ b/cocos/gfx/webgl/webgl-primary-command-buffer.ts @@ -38,6 +38,7 @@ import { WebGLTexture } from './webgl-texture'; import { RenderPass } from '../base/render-pass'; import { WebGLRenderPass } from './webgl-render-pass'; import { WebGLDeviceManager } from './webgl-define'; +import { error } from '../../core'; export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { public beginRenderPass ( @@ -86,7 +87,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { } } } else { - console.error('Command \'draw\' must be recorded inside a render pass.'); + error('Command \'draw\' must be recorded inside a render pass.'); } } @@ -138,7 +139,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { WebGLCmdFuncUpdateBuffer(WebGLDeviceManager.instance, gpuBuffer, data as ArrayBuffer, 0, buffSize); } } else { - console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); + error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -149,7 +150,7 @@ export class WebGLPrimaryCommandBuffer extends WebGLCommandBuffer { WebGLCmdFuncCopyBuffersToTexture(WebGLDeviceManager.instance, buffers, gpuTexture, regions); } } else { - console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); + error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } } diff --git a/cocos/gfx/webgl2/webgl2-buffer.ts b/cocos/gfx/webgl2/webgl2-buffer.ts index 53fbffabcc0..8055d27dc5d 100644 --- a/cocos/gfx/webgl2/webgl2-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-buffer.ts @@ -22,6 +22,7 @@ THE SOFTWARE. */ +import { warn } from '../../core'; import { Buffer } from '../base/buffer'; import { BufferUsageBit, BufferSource, BufferInfo, BufferViewInfo } from '../base/define'; import { @@ -99,7 +100,7 @@ export class WebGL2Buffer extends Buffer { public resize (size: number): void { if (this._isBufferView) { - console.warn('cannot resize buffer views!'); + warn('cannot resize buffer views!'); return; } @@ -121,7 +122,7 @@ export class WebGL2Buffer extends Buffer { public update (buffer: Readonly, size?: number): void { if (this._isBufferView) { - console.warn('cannot update through buffer views!'); + warn('cannot update through buffer views!'); return; } diff --git a/cocos/gfx/webgl2/webgl2-command-buffer.ts b/cocos/gfx/webgl2/webgl2-command-buffer.ts index c4810681b6f..34521ae6537 100644 --- a/cocos/gfx/webgl2/webgl2-command-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-command-buffer.ts @@ -60,6 +60,7 @@ import { GeneralBarrier } from '../base/states/general-barrier'; import { TextureBarrier } from '../base/states/texture-barrier'; import { BufferBarrier } from '../base/states/buffer-barrier'; import { WebGL2DeviceManager } from './webgl2-define'; +import { error } from '../../core'; export class WebGL2CommandBuffer extends CommandBuffer { public cmdPackage: WebGL2CmdPackage = new WebGL2CmdPackage(); @@ -307,7 +308,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { } } } else { - console.error('Command \'draw\' must be recorded inside a render pass.'); + error('Command \'draw\' must be recorded inside a render pass.'); } } @@ -342,7 +343,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { this.cmdPackage.cmds.push(WebGL2Cmd.UPDATE_BUFFER); } } else { - console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); + error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -362,7 +363,7 @@ export class WebGL2CommandBuffer extends CommandBuffer { this.cmdPackage.cmds.push(WebGL2Cmd.COPY_BUFFER_TO_TEXTURE); } } else { - console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); + error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } } diff --git a/cocos/gfx/webgl2/webgl2-device.ts b/cocos/gfx/webgl2/webgl2-device.ts index c46c3e65395..75eee3d6e46 100644 --- a/cocos/gfx/webgl2/webgl2-device.ts +++ b/cocos/gfx/webgl2/webgl2-device.ts @@ -62,7 +62,7 @@ import { WebGL2CmdFuncCopyTextureToBuffers, WebGL2CmdFuncCopyBuffersToTexture, W import { GeneralBarrier } from '../base/states/general-barrier'; import { TextureBarrier } from '../base/states/texture-barrier'; import { BufferBarrier } from '../base/states/buffer-barrier'; -import { debug, sys } from '../../core'; +import { debug, error, sys } from '../../core'; import { Swapchain } from '../base/swapchain'; import { IWebGL2Extensions, WebGL2DeviceManager } from './webgl2-define'; import { IWebGL2BindingMapping, IWebGL2BlitManager } from './webgl2-gpu-objects'; @@ -139,7 +139,7 @@ export class WebGL2Device extends Device { const gl = this._context = getContext(Device.canvas); if (!gl) { - console.error('This device does not support WebGL2.'); + error('This device does not support WebGL2.'); return false; } diff --git a/cocos/gfx/webgl2/webgl2-input-assembler.ts b/cocos/gfx/webgl2/webgl2-input-assembler.ts index 0b927925d9f..138a9e81f29 100644 --- a/cocos/gfx/webgl2/webgl2-input-assembler.ts +++ b/cocos/gfx/webgl2/webgl2-input-assembler.ts @@ -22,6 +22,7 @@ THE SOFTWARE. */ +import { error } from '../../core'; import { InputAssemblerInfo } from '../base/define'; import { InputAssembler } from '../base/input-assembler'; import { WebGL2Buffer } from './webgl2-buffer'; @@ -38,7 +39,7 @@ export class WebGL2InputAssembler extends InputAssembler { public initialize (info: Readonly): void { if (info.vertexBuffers.length === 0) { - console.error('InputAssemblerInfo.vertexBuffers is null.'); + error('InputAssemblerInfo.vertexBuffers is null.'); return; } @@ -77,7 +78,7 @@ export class WebGL2InputAssembler extends InputAssembler { case 2: glIndexType = 0x1403; break; // WebGLRenderingContext.UNSIGNED_SHORT case 4: glIndexType = 0x1405; break; // WebGLRenderingContext.UNSIGNED_INT default: { - console.error('Illegal index buffer stride.'); + error('Illegal index buffer stride.'); } } } diff --git a/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts b/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts index 1866ed39133..493b08e8bc0 100644 --- a/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts +++ b/cocos/gfx/webgl2/webgl2-primary-command-buffer.ts @@ -38,6 +38,7 @@ import { WebGL2Texture } from './webgl2-texture'; import { RenderPass } from '../base/render-pass'; import { WebGL2RenderPass } from './webgl2-render-pass'; import { WebGL2DeviceManager } from './webgl2-define'; +import { error } from '../../core'; export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { public beginRenderPass ( @@ -86,7 +87,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { } } } else { - console.error('Command \'draw\' must be recorded inside a render pass.'); + error('Command \'draw\' must be recorded inside a render pass.'); } } @@ -138,7 +139,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { WebGL2CmdFuncUpdateBuffer(WebGL2DeviceManager.instance, gpuBuffer, data as ArrayBuffer, 0, buffSize); } } else { - console.error('Command \'updateBuffer\' must be recorded outside a render pass.'); + error('Command \'updateBuffer\' must be recorded outside a render pass.'); } } @@ -149,7 +150,7 @@ export class WebGL2PrimaryCommandBuffer extends WebGL2CommandBuffer { WebGL2CmdFuncCopyBuffersToTexture(WebGL2DeviceManager.instance, buffers, gpuTexture, regions); } } else { - console.error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); + error('Command \'copyBufferToTexture\' must be recorded outside a render pass.'); } } diff --git a/cocos/gfx/webgl2/webgl2-texture.ts b/cocos/gfx/webgl2/webgl2-texture.ts index 824e3c2af70..6bb0cb82664 100644 --- a/cocos/gfx/webgl2/webgl2-texture.ts +++ b/cocos/gfx/webgl2/webgl2-texture.ts @@ -22,6 +22,7 @@ THE SOFTWARE. */ +import { log } from '../../core'; import { FormatSurfaceSize, TextureInfo, IsPowerOf2, TextureViewInfo, ISwapchainTextureInfo, FormatInfos, TextureUsageBit, @@ -113,7 +114,7 @@ export class WebGL2Texture extends Texture { this._gpuTexture = (viewInfo.texture as WebGL2Texture)._gpuTexture; if (this._gpuTexture?.format !== texInfo.format) { - console.log('GPU memory alias is not supported'); + log('GPU memory alias is not supported'); return; } @@ -135,7 +136,7 @@ export class WebGL2Texture extends Texture { } } - public getGLTextureHandle () : number { + public getGLTextureHandle (): number { const gpuTexture = this._gpuTexture; if (!gpuTexture) { return 0; diff --git a/cocos/input/input.ts b/cocos/input/input.ts index 8729daaa838..ec391bb387b 100644 --- a/cocos/input/input.ts +++ b/cocos/input/input.ts @@ -27,7 +27,7 @@ import { EDITOR_NOT_IN_PREVIEW, NATIVE } from 'internal:constants'; import { TouchInputSource, MouseInputSource, KeyboardInputSource, AccelerometerInputSource, GamepadInputDevice, HandleInputDevice, HMDInputDevice, HandheldInputDevice } from 'pal/input'; import { touchManager } from '../../pal/input/touch-manager'; -import { sys, EventTarget } from '../core'; +import { sys, EventTarget, error } from '../core'; import { Event, EventAcceleration, EventGamepad, EventHandle, EventHandheld, EventHMD, EventKeyboard, EventMouse, EventTouch, Touch } from './types'; import { InputEventType } from './types/event-enum'; @@ -295,8 +295,8 @@ export class Input { break; } } catch (e) { - console.error(`Error occurs in an event listener: ${event.type}`); - console.error(e); + error(`Error occurs in an event listener: ${event.type}`); + error(e); } } } diff --git a/cocos/misc/renderer.ts b/cocos/misc/renderer.ts index 8f5c9dc8e58..53f19a91193 100644 --- a/cocos/misc/renderer.ts +++ b/cocos/misc/renderer.ts @@ -26,7 +26,7 @@ import { EDITOR } from 'internal:constants'; import { Material } from '../asset/assets/material'; import { Component } from '../scene-graph'; import { IMaterialInstanceInfo, MaterialInstance } from '../render-scene/core/material-instance'; -import { warnID, _decorator } from '../core'; +import { warnID, _decorator, error } from '../core'; const _matInsInfo: IMaterialInstanceInfo = { parent: null!, @@ -163,7 +163,7 @@ export class Renderer extends Component { */ public setMaterial (material: Material | null, index: number): void { if (material && material instanceof MaterialInstance) { - console.error('Can\'t set a material instance to a sharedMaterial slot'); + error('Can\'t set a material instance to a sharedMaterial slot'); } this._materials[index] = material; const inst = this._materialInstances[index]; diff --git a/cocos/particle-2d/tiff-reader.ts b/cocos/particle-2d/tiff-reader.ts index d7ad92efb7e..6c594e5f0fa 100644 --- a/cocos/particle-2d/tiff-reader.ts +++ b/cocos/particle-2d/tiff-reader.ts @@ -28,7 +28,7 @@ THE SOFTWARE. */ -import { getError, logID } from '../core'; +import { getError, log, logID } from '../core'; import { ccwindow } from '../core/global-exports'; interface IFile { @@ -79,7 +79,7 @@ export class TiffReader { } else if (BOM === 0x4D4D) { this._littleEndian = false; } else { - console.log(BOM); + log(BOM); throw TypeError(getError(6019)); } diff --git a/cocos/particle/animator/texture-animation.ts b/cocos/particle/animator/texture-animation.ts index a08dd4f5b05..00959f9684a 100644 --- a/cocos/particle/animator/texture-animation.ts +++ b/cocos/particle/animator/texture-animation.ts @@ -23,7 +23,7 @@ */ import { ccclass, tooltip, displayOrder, type, formerlySerializedAs, serializable, range } from 'cc.decorator'; -import { lerp, pseudoRandom, repeat, Enum } from '../../core'; +import { lerp, pseudoRandom, repeat, Enum, error } from '../../core'; import { Particle, ParticleModuleBase, PARTICLE_MODULE_NAME } from '../particle'; import CurveRange from './curve-range'; import { ModuleRandSeed } from '../enum'; @@ -117,7 +117,7 @@ export default class TextureAnimationModule extends ParticleModuleBase { set mode (val) { if (val !== Mode.Grid) { - console.error('particle texture animation\'s sprites is not supported!'); + error('particle texture animation\'s sprites is not supported!'); } } @@ -207,7 +207,7 @@ export default class TextureAnimationModule extends ParticleModuleBase { } set flipU (val) { - console.error('particle texture animation\'s flipU is not supported!'); + error('particle texture animation\'s flipU is not supported!'); } @serializable @@ -218,7 +218,7 @@ export default class TextureAnimationModule extends ParticleModuleBase { } set flipV (val) { - console.error('particle texture animation\'s flipV is not supported!'); + error('particle texture animation\'s flipV is not supported!'); } @serializable @@ -229,7 +229,7 @@ export default class TextureAnimationModule extends ParticleModuleBase { } set uvChannelMask (val) { - console.error('particle texture animation\'s uvChannelMask is not supported!'); + error('particle texture animation\'s uvChannelMask is not supported!'); } /** diff --git a/cocos/particle/emitter/shape-module.ts b/cocos/particle/emitter/shape-module.ts index 2f96b9cc77a..8c48b58ee25 100644 --- a/cocos/particle/emitter/shape-module.ts +++ b/cocos/particle/emitter/shape-module.ts @@ -23,7 +23,7 @@ */ import { ccclass, tooltip, displayOrder, type, formerlySerializedAs, serializable, visible, range } from 'cc.decorator'; -import { Mat4, Quat, Vec2, Vec3, clamp, pingPong, random, randomRange, repeat, toDegree, toRadian } from '../../core'; +import { Mat4, Quat, Vec2, Vec3, clamp, pingPong, random, randomRange, repeat, toDegree, toRadian, warn } from '../../core'; import CurveRange from '../animator/curve-range'; import { ArcMode, EmitLocation, ShapeType } from '../enum'; @@ -424,7 +424,7 @@ export default class ShapeModule { hemisphereEmit(this.emitFrom, this.radius, this.radiusThickness, p.position, p.velocity); break; default: - console.warn(`${this.shapeType} shapeType is not supported by ShapeModule.`); + warn(`${this.shapeType} shapeType is not supported by ShapeModule.`); } if (this.randomPositionAmount > 0) { p.position.x += randomRange(-this.randomPositionAmount, this.randomPositionAmount); @@ -477,7 +477,7 @@ function sphereEmit (emitFrom, radius, radiusThickness, pos, dir): void { Vec3.normalize(dir, pos); break; default: - console.warn(`${emitFrom} is not supported for sphere emitter.`); + warn(`${emitFrom} is not supported for sphere emitter.`); } } @@ -499,7 +499,7 @@ function hemisphereEmit (emitFrom, radius, radiusThickness, pos, dir): void { Vec3.normalize(dir, pos); break; default: - console.warn(`${emitFrom} is not supported for hemisphere emitter.`); + warn(`${emitFrom} is not supported for hemisphere emitter.`); } } @@ -529,7 +529,7 @@ function coneEmit (emitFrom, radius, radiusThickness, theta, angle, length, pos, Vec3.add(pos, pos, Vec3.multiplyScalar(_intermediVec, dir, length * random() / -dir.z)); break; default: - console.warn(`${emitFrom} is not supported for cone emitter.`); + warn(`${emitFrom} is not supported for cone emitter.`); } } @@ -558,7 +558,7 @@ function boxEmit (emitFrom, boxThickness, pos, dir): void { Vec3.set(pos, _intermediArr[0], _intermediArr[1], _intermediArr[2]); break; default: - console.warn(`${emitFrom} is not supported for box emitter.`); + warn(`${emitFrom} is not supported for box emitter.`); } Vec3.copy(dir, particleEmitZAxis); } diff --git a/cocos/particle/particle-system.ts b/cocos/particle/particle-system.ts index c572b77a671..ff5b081b2ba 100644 --- a/cocos/particle/particle-system.ts +++ b/cocos/particle/particle-system.ts @@ -261,7 +261,7 @@ export class ParticleSystem extends ModelRenderer { set prewarm (val) { if (val === true && this.loop === false) { - // console.warn('prewarm only works if loop is also enabled.'); + // warn('prewarm only works if loop is also enabled.'); } this._prewarm = val; } diff --git a/cocos/particle/renderer/particle-system-renderer-cpu.ts b/cocos/particle/renderer/particle-system-renderer-cpu.ts index 677758a9c69..69339acf680 100644 --- a/cocos/particle/renderer/particle-system-renderer-cpu.ts +++ b/cocos/particle/renderer/particle-system-renderer-cpu.ts @@ -26,7 +26,7 @@ import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; import { builtinResMgr } from '../../asset/asset-manager'; import { Material } from '../../asset/assets'; import { AttributeName, Format, Attribute, FormatInfos } from '../../gfx'; -import { Mat4, Vec2, Vec3, Vec4, pseudoRandom, Quat, EPSILON, approx, RecyclePool } from '../../core'; +import { Mat4, Vec2, Vec3, Vec4, pseudoRandom, Quat, EPSILON, approx, RecyclePool, warn } from '../../core'; import { MaterialInstance, IMaterialInstanceInfo } from '../../render-scene/core/material-instance'; import { MacroRecord } from '../../render-scene/core/pass-utils'; import { AlignmentSpace, RenderMode, Space } from '../enum'; @@ -680,7 +680,7 @@ export default class ParticleSystemRendererCPU extends ParticleSystemRendererBas } else if (renderMode === RenderMode.Mesh) { this._defines[CC_RENDER_MODE] = RENDER_MODE_MESH; } else { - console.warn(`particle system renderMode ${renderMode} not support.`); + warn(`particle system renderMode ${renderMode} not support.`); } const textureModule = ps._textureAnimationModule; if (textureModule && textureModule.enable) { diff --git a/cocos/particle/renderer/particle-system-renderer-gpu.ts b/cocos/particle/renderer/particle-system-renderer-gpu.ts index 894fc246ab8..2d4ce8e8f6c 100644 --- a/cocos/particle/renderer/particle-system-renderer-gpu.ts +++ b/cocos/particle/renderer/particle-system-renderer-gpu.ts @@ -27,7 +27,7 @@ import { builtinResMgr } from '../../asset/asset-manager'; import { Material, Texture2D } from '../../asset/assets'; import { Component } from '../../scene-graph'; import { AttributeName, Format, Attribute, API, deviceManager, FormatInfos } from '../../gfx'; -import { Mat4, Vec2, Vec4, Quat, Vec3 } from '../../core'; +import { Mat4, Vec2, Vec4, Quat, Vec3, warn } from '../../core'; import { MaterialInstance, IMaterialInstanceInfo } from '../../render-scene/core/material-instance'; import { MacroRecord } from '../../render-scene/core/pass-utils'; import { AlignmentSpace, RenderMode, Space } from '../enum'; @@ -611,7 +611,7 @@ export default class ParticleSystemRendererGPU extends ParticleSystemRendererBas } else if (renderMode === RenderMode.Mesh) { this._defines[CC_RENDER_MODE] = RENDER_MODE_MESH; } else { - console.warn(`particle system renderMode ${renderMode} not support.`); + warn(`particle system renderMode ${renderMode} not support.`); } const textureModule = ps._textureAnimationModule; if (textureModule && textureModule.enable) { diff --git a/cocos/particle/renderer/trail.ts b/cocos/particle/renderer/trail.ts index 3dad5a3d748..3493c6fea14 100644 --- a/cocos/particle/renderer/trail.ts +++ b/cocos/particle/renderer/trail.ts @@ -156,7 +156,7 @@ class TrailSegment { // ' velocity:' + e.velocity.toString() + '\n'; // return false; // }, null, 0); - // console.log(msg); + // log(msg); // } } @@ -773,7 +773,7 @@ export default class TrailModule { // log += 'vel:' + this._vbF32![i++].toFixed(2) + ',' + this._vbF32![i++].toFixed(2) + ',' + this._vbF32![i++].toFixed(2) + '\n'; // } // if (log.length > 0) { - // console.log(log); + // log(log); // } // } } diff --git a/cocos/physics-2d/box2d/shapes/polygon-shape-2d.ts b/cocos/physics-2d/box2d/shapes/polygon-shape-2d.ts index ba04cec60a8..d112aba37bc 100644 --- a/cocos/physics-2d/box2d/shapes/polygon-shape-2d.ts +++ b/cocos/physics-2d/box2d/shapes/polygon-shape-2d.ts @@ -29,7 +29,7 @@ import * as PolygonPartition from '../../framework/utils/polygon-partition'; import { PolygonCollider2D } from '../../framework'; import { PHYSICS_2D_PTM_RATIO } from '../../framework/physics-types'; import { IPolygonShape } from '../../spec/i-physics-shape'; -import { Vec2, IVec2Like } from '../../../core'; +import { Vec2, IVec2Like, log } from '../../../core'; export class b2PolygonShape extends b2Shape2D implements IPolygonShape { _worldPoints: Vec2[] = []; @@ -62,7 +62,7 @@ export class b2PolygonShape extends b2Shape2D implements IPolygonShape { const polys = PolygonPartition.ConvexPartition(points); if (!polys) { - console.log('[Physics2D] b2PolygonShape failed to decompose polygon into convex polygons, node name: ', comp.node.name); + log('[Physics2D] b2PolygonShape failed to decompose polygon into convex polygons, node name: ', comp.node.name); return shapes; } diff --git a/cocos/physics-2d/framework/physics-selector.ts b/cocos/physics-2d/framework/physics-selector.ts index 3af13810d8a..654756e4ebb 100644 --- a/cocos/physics-2d/framework/physics-selector.ts +++ b/cocos/physics-2d/framework/physics-selector.ts @@ -27,7 +27,7 @@ import { EDITOR, DEBUG, TEST, EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; import { IRigidBody2D } from '../spec/i-rigid-body'; import { IBoxShape, ICircleShape, IPolygonShape, IBaseShape } from '../spec/i-physics-shape'; import { IPhysicsWorld } from '../spec/i-physics-world'; -import { errorID } from '../../core'; +import { errorID, log } from '../../core'; import { ECollider2DType, EJoint2DType } from './physics-types'; import { IJoint2D, IDistanceJoint, ISpringJoint, IFixedJoint, IMouseJoint, IRelativeJoint, ISliderJoint, IWheelJoint, IHingeJoint } from '../spec/i-physics-joint'; @@ -109,7 +109,7 @@ export interface IPhysicsSelector { } function register (id: IPhysicsEngineId, wrapper: IPhysicsWrapperObject): void { - if (!EDITOR && !TEST) console.info(`[PHYSICS2D]: register ${id}.`); + if (!EDITOR && !TEST) log(`[PHYSICS2D]: register ${id}.`); selector.backend[id] = wrapper; if (!selector.physicsWorld || selector.id === id) { const mutableSelector = selector as Mutable; @@ -123,12 +123,12 @@ function switchTo (id: IPhysicsEngineId): void { const mutableSelector = selector as Mutable; if (selector.physicsWorld && id !== selector.id && selector.backend[id] != null) { //selector.physicsWorld.destroy();//todo - if (!TEST) console.info(`[PHYSICS2D]: switch from ${selector.id} to ${id}.`); + if (!TEST) log(`[PHYSICS2D]: switch from ${selector.id} to ${id}.`); mutableSelector.id = id; mutableSelector.wrapper = selector.backend[id]; mutableSelector.physicsWorld = createPhysicsWorld(); } else { - if (!EDITOR && !TEST) console.info(`[PHYSICS2D]: using ${mutableSelector.id}.`); + if (!EDITOR && !TEST) log(`[PHYSICS2D]: using ${mutableSelector.id}.`); mutableSelector.physicsWorld = createPhysicsWorld(); } } diff --git a/cocos/physics-2d/framework/utils/polygon-partition.ts b/cocos/physics-2d/framework/utils/polygon-partition.ts index 625900b1b70..c98c114abb6 100644 --- a/cocos/physics-2d/framework/utils/polygon-partition.ts +++ b/cocos/physics-2d/framework/utils/polygon-partition.ts @@ -22,7 +22,7 @@ THE SOFTWARE. */ -import { IVec2Like } from '../../../core'; +import { IVec2Like, log } from '../../../core'; //https://github.com/x6ud/poly-partition-js @@ -278,7 +278,7 @@ function Triangulate (polygon: IVec2Like[]): IVec2Like[][] | null { const p2 = vertex.point!; const p3 = vertex.next!.point!; if (Math.abs(area(p1, p2, p3)) > 1e-5) { - console.log('Failed to find ear. There might be self-intersection in the polygon.'); + log('Failed to find ear. There might be self-intersection in the polygon.'); return null; } } diff --git a/cocos/physics/bullet/instantiated.ts b/cocos/physics/bullet/instantiated.ts index 92997dce5f9..292bd7512ab 100644 --- a/cocos/physics/bullet/instantiated.ts +++ b/cocos/physics/bullet/instantiated.ts @@ -27,7 +27,7 @@ import { CULL_ASM_JS_MODULE, FORCE_BANNING_BULLET_WASM, WASM_SUPPORT_MODE } from import bulletWasmUrl from 'external:emscripten/bullet/bullet.wasm'; import asmFactory from 'external:emscripten/bullet/bullet.asm.js'; import { game } from '../../game'; -import { debug, error, getError, sys } from '../../core'; +import { debug, error, getError, log, sys } from '../../core'; import { pageSize, pageCount, importFunc } from './bullet-env'; import { WebAssemblySupportMode } from '../../misc/webassembly-support'; @@ -93,7 +93,7 @@ function initAsm (resolve, reject): void { } function getImportObject (): WebAssembly.Imports { - const infoReport = (msg: any): void => { console.info(msg); }; + const infoReport = (msg: any): void => { log(msg); }; const memory = new WebAssembly.Memory({ initial: pageCount }); const importObject = { cc: importFunc, diff --git a/cocos/physics/framework/physics-selector.ts b/cocos/physics/framework/physics-selector.ts index b7041aa82f0..1cd9c539207 100644 --- a/cocos/physics/framework/physics-selector.ts +++ b/cocos/physics/framework/physics-selector.ts @@ -35,7 +35,7 @@ import { import { IPhysicsWorld } from '../spec/i-physics-world'; import { IRigidBody } from '../spec/i-rigid-body'; import { IBoxCharacterController, ICapsuleCharacterController } from '../spec/i-character-controller'; -import { errorID, IVec3Like, warn, cclegacy } from '../../core'; +import { errorID, IVec3Like, warn, cclegacy, debug } from '../../core'; import { EColliderType, EConstraintType, ECharacterControllerType } from './physics-enum'; import { PhysicsMaterial } from '.'; @@ -125,7 +125,7 @@ function updateLegacyMacro (id: string): void { } function register (id: IPhysicsEngineId, wrapper: IPhysicsWrapperObject): void { - if (!EDITOR && !TEST) console.info(`[PHYSICS]: register ${id}.`); + if (!EDITOR && !TEST) debug(`[PHYSICS]: register ${id}.`); selector.backend[id] = wrapper; if (!selector.physicsWorld || selector.id === id) { updateLegacyMacro(id); @@ -147,13 +147,13 @@ function switchTo (id: IPhysicsEngineId): void { const mutableSelector = selector as Mutable; if (selector.physicsWorld && id !== selector.id && selector.backend[id] != null) { selector.physicsWorld.destroy(); - if (!TEST) console.info(`[PHYSICS]: switch from ${selector.id} to ${id}.`); + if (!TEST) debug(`[PHYSICS]: switch from ${selector.id} to ${id}.`); updateLegacyMacro(id); mutableSelector.id = id; mutableSelector.wrapper = selector.backend[id]; mutableSelector.physicsWorld = createPhysicsWorld(); } else { - if (!EDITOR && !TEST) console.info(`[PHYSICS]: using ${id}.`); + if (!EDITOR && !TEST) debug(`[PHYSICS]: using ${id}.`); mutableSelector.physicsWorld = createPhysicsWorld(); } if (worldInitData) { @@ -185,7 +185,7 @@ export function constructDefaultWorld (data: IWorldInitData): void { if (!worldInitData) worldInitData = data; if (!selector.runInEditor) return; if (!selector.physicsWorld) { - if (!TEST) console.info(`[PHYSICS]: using ${selector.id}.`); + if (!TEST) debug(`[PHYSICS]: using ${selector.id}.`); const mutableSelector = selector as Mutable; const world = mutableSelector.physicsWorld = createPhysicsWorld(); world.setGravity(worldInitData.gravity); diff --git a/cocos/physics/framework/physics-system.ts b/cocos/physics/framework/physics-system.ts index ae6668b9642..59b35b85f2c 100644 --- a/cocos/physics/framework/physics-system.ts +++ b/cocos/physics/framework/physics-system.ts @@ -23,7 +23,7 @@ */ import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants'; -import { Vec3, RecyclePool, Enum, System, cclegacy, Settings, settings, geometry, warn, IQuatLike, IVec3Like } from '../../core'; +import { Vec3, RecyclePool, Enum, System, cclegacy, Settings, settings, geometry, warn, IQuatLike, IVec3Like, error } from '../../core'; import { IPhysicsWorld, IRaycastOptions } from '../spec/i-physics-world'; import { director, Director, game } from '../../game'; import { PhysicsMaterial } from './assets/physics-material'; @@ -224,7 +224,7 @@ export class PhysicsSystem extends System implements IWorldInitData { const builtinMaterial = builtinResMgr.get('default-physics-material'); if (!builtinMaterial) { - console.error('PhysicsSystem initDefaultMaterial() Failed to load builtinMaterial'); + error('PhysicsSystem initDefaultMaterial() Failed to load builtinMaterial'); return Promise.resolve(); } diff --git a/cocos/physics/physx/physx-adapter.ts b/cocos/physics/physx/physx-adapter.ts index 0ef51b2e365..505c1526c04 100644 --- a/cocos/physics/physx/physx-adapter.ts +++ b/cocos/physics/physx/physx-adapter.ts @@ -35,7 +35,7 @@ import { wasmFactory, PhysXWasmUrl } from './physx.wasmjs'; import { WebAssemblySupportMode } from '../../misc/webassembly-support'; import { instantiateWasm } from 'pal/wasm'; import { BYTEDANCE, DEBUG, EDITOR, TEST, WASM_SUPPORT_MODE } from 'internal:constants'; -import { IQuatLike, IVec3Like, Quat, RecyclePool, Vec3, cclegacy, geometry, Settings, settings, sys } from '../../core'; +import { IQuatLike, IVec3Like, Quat, RecyclePool, Vec3, cclegacy, geometry, Settings, settings, sys, debug, error } from '../../core'; import { shrinkPositions } from '../utils/util'; import { IRaycastOptions } from '../spec/i-physics-world'; import { IPhysicsConfig, PhysicsRayResult, PhysicsSystem, CharacterControllerContact } from '../framework'; @@ -59,7 +59,7 @@ game.onPostInfrastructureInitDelegate.add(InitPhysXLibs); export function InitPhysXLibs (): any { if (USE_BYTEDANCE) { - if (!EDITOR && !TEST) console.debug('[PHYSICS]:', `Use PhysX Libs in BYTEDANCE.`); + if (!EDITOR && !TEST) debug('[PHYSICS]:', `Use PhysX Libs in BYTEDANCE.`); Object.assign(PX, globalThis.nativePhysX); Object.assign(_pxtrans, new PX.Transform(_v3, _v4)); _pxtrans.setPosition = PX.Transform.prototype.setPosition.bind(_pxtrans); @@ -84,13 +84,13 @@ function initASM (): any { globalThis.PhysX = globalThis.PHYSX ? globalThis.PHYSX : asmFactory; if (globalThis.PhysX != null) { return globalThis.PhysX().then((Instance: any): void => { - if (!EDITOR && !TEST) console.debug('[PHYSICS]:', `${USE_EXTERNAL_PHYSX ? 'External' : 'Internal'} PhysX asm libs loaded.`); + if (!EDITOR && !TEST) debug('[PHYSICS]:', `${USE_EXTERNAL_PHYSX ? 'External' : 'Internal'} PhysX asm libs loaded.`); initAdaptWrapper(Instance); initConfigAndCacheObject(Instance); Object.assign(PX, Instance); - }, (reason: any): void => { console.error('[PHYSICS]:', `PhysX asm load failed: ${reason}`); }); + }, (reason: any): void => { error('[PHYSICS]:', `PhysX asm load failed: ${reason}`); }); } else { - if (!EDITOR && !TEST) console.error('[PHYSICS]:', 'Failed to load PhysX js libs, package may be not found.'); + if (!EDITOR && !TEST) error('[PHYSICS]:', 'Failed to load PhysX js libs, package may be not found.'); return new Promise((resolve, reject): void => { resolve(); }); @@ -108,13 +108,13 @@ function initWASM (): any { }); }, }).then((Instance: any): void => { - if (!EDITOR && !TEST) console.debug('[PHYSICS]:', `${USE_EXTERNAL_PHYSX ? 'External' : 'Internal'} PhysX wasm libs loaded.`); + if (!EDITOR && !TEST) debug('[PHYSICS]:', `${USE_EXTERNAL_PHYSX ? 'External' : 'Internal'} PhysX wasm libs loaded.`); initAdaptWrapper(Instance); initConfigAndCacheObject(Instance); Object.assign(PX, Instance); - }, (reason: any): void => { console.error('[PHYSICS]:', `PhysX wasm load failed: ${reason}`); }); + }, (reason: any): void => { error('[PHYSICS]:', `PhysX wasm load failed: ${reason}`); }); } else { - if (!EDITOR && !TEST) console.error('[PHYSICS]:', 'Failed to load PhysX wasm libs, package may be not found.'); + if (!EDITOR && !TEST) error('[PHYSICS]:', 'Failed to load PhysX wasm libs, package may be not found.'); return new Promise((resolve, reject): void => { resolve(); }); @@ -444,7 +444,7 @@ export function createBV33TriangleMesh (vertices: number[], indices: Uint32Array params.setMidphaseDesc(midDesc); cooking.setParams(params); - console.info(`[PHYSICS]: cook bvh33 status:${cooking.validateTriangleMesh(meshDesc)}`); + debug(`[PHYSICS]: cook bvh33 status:${cooking.validateTriangleMesh(meshDesc)}`); return cooking.createTriangleMesh(meshDesc); } @@ -464,7 +464,7 @@ export function createBV34TriangleMesh (vertices: number[], indices: Uint32Array midDesc.setNumPrimsLeaf(numTrisPerLeaf); params.setMidphaseDesc(midDesc); cooking.setParams(params); - console.info(`[PHYSICS]: cook bvh34 status:${cooking.validateTriangleMesh(meshDesc)}`); + debug(`[PHYSICS]: cook bvh34 status:${cooking.validateTriangleMesh(meshDesc)}`); return cooking.createTriangleMesh(meshDesc); } @@ -561,7 +561,7 @@ export function raycastAll (world: PhysXWorld, worldRay: geometry.Ray, options: return true; } if (r === -1) { // eslint-disable-next-line no-console - console.error('not enough memory.'); + error('not enough memory.'); } } return false; @@ -631,7 +631,7 @@ export function sweepAll (world: PhysXWorld, worldRay: geometry.Ray, geometry: a return true; } if (r === -1) { // eslint-disable-next-line no-console - console.error('not enough memory.'); + error('not enough memory.'); } return false; @@ -681,9 +681,9 @@ export function initializeWorld (world: any): void { const mstc = sceneDesc.getMaxSubThreadCount(); const count = PX.SUB_THREAD_COUNT > mstc ? mstc : PX.SUB_THREAD_COUNT; sceneDesc.setSubThreadCount(count); - console.info('[PHYSICS][PhysX]:', `use muti-thread mode, sub thread count: ${count}, max count: ${mstc}`); + debug('[PHYSICS][PhysX]:', `use muti-thread mode, sub thread count: ${count}, max count: ${mstc}`); } else { - console.info('[PHYSICS][PhysX]:', 'use single-thread mode'); + debug('[PHYSICS][PhysX]:', 'use single-thread mode'); } sceneDesc.setFlag(PX.SceneFlag.eENABLE_PCM, true); sceneDesc.setFlag(PX.SceneFlag.eENABLE_CCD, true); diff --git a/cocos/render-scene/core/memory-pools.ts b/cocos/render-scene/core/memory-pools.ts index c4c17024b13..5a1350e4725 100644 --- a/cocos/render-scene/core/memory-pools.ts +++ b/cocos/render-scene/core/memory-pools.ts @@ -24,6 +24,7 @@ import { DEBUG } from 'internal:constants'; import { NativeBufferPool } from './native-pools'; +import { warn } from '../../core'; const contains = (a: number[], t: number): boolean => { for (let i = 0; i < a.length; ++i) { @@ -50,7 +51,7 @@ enum BufferDataType { NEVER, } -type BufferManifest = { [key: string]: number | string; COUNT: number }; +interface BufferManifest { [key: string]: number | string; COUNT: number } type BufferDataTypeManifest = { [key in E[keyof E]]: BufferDataType }; type BufferDataMembersManifest = { [key in E[keyof E]]: number }; type BufferArrayType = Float32Array | Uint32Array; @@ -143,7 +144,7 @@ class BufferPool

implements IMemor const bufferViews = this._hasFloat32 ? this._float32BufferViews : this._uint32BufferViews; if (DEBUG && (!handle || chunk < 0 || chunk >= bufferViews.length || entry < 0 || entry >= this._entriesPerChunk || contains(this._freeLists[chunk], entry))) { - console.warn('invalid buffer pool handle'); + warn('invalid buffer pool handle'); return [] as unknown as BufferArrayType; } @@ -156,7 +157,7 @@ class BufferPool

implements IMemor const bufferViews = this._dataType[element] === BufferDataType.UINT32 ? this._uint32BufferViews : this._float32BufferViews; if (DEBUG && (!handle || chunk < 0 || chunk >= bufferViews.length || entry < 0 || entry >= this._entriesPerChunk || contains(this._freeLists[chunk], entry))) { - console.warn('invalid buffer pool handle'); + warn('invalid buffer pool handle'); return [] as unknown as BufferArrayType; } const index = element as unknown as number; @@ -171,7 +172,7 @@ class BufferPool

implements IMemor const entry = this._entryMask & handle as unknown as number; if (DEBUG && (!handle || chunk < 0 || chunk >= this._freeLists.length || entry < 0 || entry >= this._entriesPerChunk || contains(this._freeLists[chunk], entry))) { - console.warn('invalid buffer pool handle'); + warn('invalid buffer pool handle'); return; } const bufferViews = this._hasUint32 ? this._uint32BufferViews : this._float32BufferViews; diff --git a/cocos/render-scene/core/pass.jsb.ts b/cocos/render-scene/core/pass.jsb.ts index 1240ec260cf..e28e5250117 100644 --- a/cocos/render-scene/core/pass.jsb.ts +++ b/cocos/render-scene/core/pass.jsb.ts @@ -26,6 +26,7 @@ import { EffectAsset } from '../../asset/assets/effect-asset'; import type { Pass as JsbPass } from './pass'; import { Mat3, Mat4, Quat, Vec2, Vec3, Vec4 } from '../../core'; import { MathType } from '../../core/math/math-native-ext'; +import { error } from "console"; declare const jsb: any; @@ -83,16 +84,16 @@ proto.getUniform = function getUniform(handle: numbe Quat.copy(out as Quat, val); break; default: - console.error(`getUniform, unknown object type: ${val.type}`); + error(`getUniform, unknown object type: ${val.type}`); break; } } else { - console.error(`getUniform, unknown object: ${val}`); + error(`getUniform, unknown object: ${val}`); } } else if (typeof val === 'number') { (out as number) = val; } else { - console.error(`getUniform, not supported: ${val}`); + error(`getUniform, not supported: ${val}`); } return out; diff --git a/cocos/render-scene/core/program-lib.ts b/cocos/render-scene/core/program-lib.ts index 9c8095ca7d3..0f46532e52b 100644 --- a/cocos/render-scene/core/program-lib.ts +++ b/cocos/render-scene/core/program-lib.ts @@ -36,7 +36,7 @@ import { } from '../../gfx'; import { genHandles, getActiveAttributes, getShaderInstanceName, getSize, getVariantKey, IMacroInfo, populateMacros, prepareDefines } from './program-utils'; -import { debug, cclegacy } from '../../core'; +import { debug, cclegacy, warn, error } from '../../core'; const _dsLayoutInfo = new DescriptorSetLayoutInfo(); @@ -74,7 +74,7 @@ function insertBuiltinBindings ( const info = source.layouts[b.name] as UniformBlock | undefined; const binding = info && source.bindings.find((bd): boolean => bd.binding === info.binding); if (!info || !binding || !(binding.descriptorType & DESCRIPTOR_BUFFER_TYPE)) { - console.warn(`builtin UBO '${b.name}' not available!`); + warn(`builtin UBO '${b.name}' not available!`); continue; } tempBlocks.push(info); @@ -87,7 +87,7 @@ function insertBuiltinBindings ( const info = source.layouts[s.name] as UniformSamplerTexture; const binding = info && source.bindings.find((bd): boolean => bd.binding === info.binding); if (!info || !binding || !(binding.descriptorType & DESCRIPTOR_SAMPLER_TYPE)) { - console.warn(`builtin samplerTexture '${s.name}' not available!`); + warn(`builtin samplerTexture '${s.name}' not available!`); continue; } tempSamplerTextures.push(info); @@ -543,7 +543,7 @@ export class ProgramLib { if (deviceShaderVersion) { src = tmpl[deviceShaderVersion]; } else { - console.error('Invalid GFX API!'); + error('Invalid GFX API!'); } tmplInfo.shaderInfo.stages[0].source = prefix + src.vert; tmplInfo.shaderInfo.stages[1].source = prefix + src.frag; diff --git a/cocos/render-scene/core/program-utils.ts b/cocos/render-scene/core/program-utils.ts index 080e2b7bfcd..e020a7f0ed1 100644 --- a/cocos/render-scene/core/program-utils.ts +++ b/cocos/render-scene/core/program-utils.ts @@ -23,6 +23,7 @@ ****************************************************************************/ import { EffectAsset } from '../../asset/assets/effect-asset'; +import { error, warn } from '../../core'; import { Attribute, GetTypeSize, ShaderInfo, Uniform } from '../../gfx/base/define'; import { UBOForwardLight, UBOSkinning } from '../../rendering/define'; import { genHandle, MacroRecord } from './pass-utils'; @@ -40,7 +41,7 @@ function mapDefine (info: EffectAsset.IDefineInfo, def: number | string | boolea case 'string': return def !== undefined ? def as string : info.options![0]; case 'number': return def !== undefined ? def.toString() : info.range![0].toString(); default: - console.warn(`unknown define type '${info.type}'`); + warn(`unknown define type '${info.type}'`); return '-1'; // should neven happen } } @@ -130,7 +131,7 @@ function getUniformSize (prevSize: number, m: Uniform): number { if (count !== undefined) { return prevSize + GetTypeSize(m.type) * count; } - console.error(`uniform '${m.name}' must have a count`); + error(`uniform '${m.name}' must have a count`); } return prevSize; } diff --git a/cocos/render-scene/utils.ts b/cocos/render-scene/utils.ts index 7ed32973f1a..ff1dc948d62 100644 --- a/cocos/render-scene/utils.ts +++ b/cocos/render-scene/utils.ts @@ -22,12 +22,13 @@ THE SOFTWARE. */ +import { error } from '../core'; import { Attribute, Buffer, BufferInfo, Device, InputAssemblerInfo, AttributeName, BufferUsageBit, Format, MemoryUsageBit, InputAssembler } from '../gfx'; import { IGeometry } from '../primitive/define'; export function createIA (device: Device, data: IGeometry): InputAssembler | null { if (!data.positions) { - console.error('The data must have positions field'); + error('The data must have positions field'); return null; } diff --git a/cocos/rendering/custom/layout-graph-utils.ts b/cocos/rendering/custom/layout-graph-utils.ts index 6787df02880..2bbcc998654 100644 --- a/cocos/rendering/custom/layout-graph-utils.ts +++ b/cocos/rendering/custom/layout-graph-utils.ts @@ -24,7 +24,7 @@ /* eslint-disable max-len */ import { EffectAsset } from '../../asset/assets'; -import { assert } from '../../core'; +import { assert, error, warn } from '../../core'; import { DescriptorSetInfo, DescriptorSetLayout, DescriptorSetLayoutBinding, DescriptorSetLayoutInfo, DescriptorType, Device, PipelineLayout, PipelineLayoutInfo, ShaderStageFlagBit, Type, Uniform, UniformBlock } from '../../gfx'; import { DefaultVisitor, depthFirstSearch, GraphColor, MutableVertexPropertyMap } from './graph'; import { DescriptorBlockData, DescriptorData, DescriptorDB, DescriptorSetData, DescriptorSetLayoutData, LayoutGraph, LayoutGraphData, LayoutGraphDataValue, LayoutGraphValue, PipelineLayoutData, RenderPassType, RenderPhase, RenderPhaseData, RenderStageData, ShaderProgramData } from './layout-graph'; @@ -109,7 +109,7 @@ export function getGfxDescriptorType (type: DescriptorTypeOrder): DescriptorType case DescriptorTypeOrder.INPUT_ATTACHMENT: return DescriptorType.INPUT_ATTACHMENT; default: - console.error('DescriptorType not found'); + error('DescriptorType not found'); return DescriptorType.INPUT_ATTACHMENT; } } @@ -137,7 +137,7 @@ export function getDescriptorTypeOrder (type: DescriptorType): DescriptorTypeOrd return DescriptorTypeOrder.INPUT_ATTACHMENT; case DescriptorType.UNKNOWN: default: - console.error('DescriptorTypeOrder not found'); + error('DescriptorTypeOrder not found'); return DescriptorTypeOrder.INPUT_ATTACHMENT; } } @@ -460,7 +460,7 @@ export class VisibilityBlock { public getVisibility (name: string): ShaderStageFlagBit { const v = this.descriptors.get(name); if (v === undefined) { - console.error(`Can't find visibility for descriptor: ${name}`); + error(`Can't find visibility for descriptor: ${name}`); return ShaderStageFlagBit.NONE; } return v; @@ -542,7 +542,7 @@ export class VisibilityGraph { continue; } if (shader.descriptors === undefined) { - console.warn(`No descriptors in shader: ${programName}, please reimport ALL effects`); + warn(`No descriptors in shader: ${programName}, please reimport ALL effects`); continue; } const passName = getPassName(pass); @@ -675,7 +675,7 @@ export class LayoutGraphInfo { return; } if (value.type !== type) { - console.warn(`Type mismatch for descriptor ${name}`); + warn(`Type mismatch for descriptor ${name}`); } } private addUniformBlock (block: DescriptorBlock, @@ -686,7 +686,7 @@ export class LayoutGraphInfo { return; } if (!this.checkConsistency(value, gfxBlock)) { - console.warn(`Uniform block ${name} is inconsistent in the same block`); + warn(`Uniform block ${name} is inconsistent in the same block`); } } private buildBlocks (visDB: VisibilityDB, rate: UpdateFrequency, blocks: EffectAsset.IBlockInfo[], db: DescriptorDB, counter: DescriptorCounter): void { @@ -807,11 +807,11 @@ export class LayoutGraphInfo { } } if (!shader) { - console.warn(`program: ${programName} not found`); + warn(`program: ${programName} not found`); continue; } if (shader.descriptors === undefined) { - console.warn(`No descriptors in shader: ${programName}, please reimport ALL effects`); + warn(`No descriptors in shader: ${programName}, please reimport ALL effects`); continue; } // get database @@ -872,13 +872,13 @@ export class LayoutGraphInfo { const phaseID = v; const parentID = lg.getParent(phaseID); if (lg.id(parentID) !== LayoutGraphValue.RenderStage) { - console.error(`phase: ${lg.getName(phaseID)} has no parent stage`); + error(`phase: ${lg.getName(phaseID)} has no parent stage`); return 1; } const phaseDB = lg.getDescriptors(phaseID); const passVisDB = visMap.get(parentID); if (!passVisDB) { - console.error(`pass: ${lg.getName(parentID)} has no visibility database`); + error(`pass: ${lg.getName(parentID)} has no visibility database`); return 1; } // merge phase visibility to pass visibility @@ -902,14 +902,14 @@ export class LayoutGraphInfo { const phaseID = v; const parentID = lg.getParent(phaseID); if (lg.id(parentID) !== LayoutGraphValue.RenderStage) { - console.error(`phase: ${lg.getName(phaseID)} has no parent stage`); + error(`phase: ${lg.getName(phaseID)} has no parent stage`); return 1; } const passDB = lg.getDescriptors(parentID); const phaseDB = lg.getDescriptors(phaseID); const passVisDB = visMap.get(parentID); if (passVisDB === undefined) { - console.error(`pass: ${lg.getName(parentID)} has no visibility database`); + error(`pass: ${lg.getName(parentID)} has no visibility database`); return 1; } for (const [key0, block] of phaseDB.blocks) { @@ -943,7 +943,7 @@ export class LayoutGraphInfo { } const b = block.uniformBlocks.get(name); if (!b) { - console.error(`uniform block: ${name} not found`); + error(`uniform block: ${name} not found`); return 1; } this.addUniformBlock(passBlock, name, b); @@ -968,22 +968,22 @@ export class LayoutGraphInfo { for (const e of lg.children(passID)) { const phaseID = lg.child(e); if (lg.id(phaseID) !== LayoutGraphValue.RenderPhase) { - console.error(`pass: ${lg.getName(passID)} is not single_render_pass or render_subpass`); + error(`pass: ${lg.getName(passID)} is not single_render_pass or render_subpass`); return 1; } const phaseDB = lg.getDescriptors(phaseID); for (const [key, passBlock] of passDB.blocks) { const index: DescriptorBlockIndex = JSON.parse(key); if (index.updateFrequency !== UpdateFrequency.PER_PASS) { - console.error(`phase: ${lg.getName(phaseID)} update frequency is not PER_PASS`); + error(`phase: ${lg.getName(phaseID)} update frequency is not PER_PASS`); return 1; } if (passBlock.count === 0) { - console.error(`pass: ${lg.getName(passID)} count is 0`); + error(`pass: ${lg.getName(passID)} count is 0`); return 1; } if (passBlock.capacity !== passBlock.count) { - console.error(`pass: ${lg.getName(passID)} capacity does not equal count`); + error(`pass: ${lg.getName(passID)} capacity does not equal count`); return 1; } const phaseBlock = this.getDescriptorBlock(key, phaseDB); @@ -1000,7 +1000,7 @@ export class LayoutGraphInfo { } } } - // console.debug(this.print()); + // debug(this.print()); return 0; } public print (): string { @@ -1047,7 +1047,7 @@ function buildLayoutGraphDataImpl (graph: LayoutGraph, builder: LayoutGraphBuild } const vertID = builder.addRenderStage(graph.getName(v), parentID); if (vertID !== v) { - console.error('vertex id mismatch'); + error('vertex id mismatch'); } minLevel = UpdateFrequency.PER_PASS; maxLevel = UpdateFrequency.PER_PASS; @@ -1059,7 +1059,7 @@ function buildLayoutGraphDataImpl (graph: LayoutGraph, builder: LayoutGraphBuild assert(parentType === RenderPassType.RENDER_SUBPASS || parentType === RenderPassType.SINGLE_RENDER_PASS); const vertID = builder.addRenderPhase(graph.getName(v), parentID); if (vertID !== v) { - console.error('vertex id mismatch'); + error('vertex id mismatch'); } const phase = graph.getRenderPhase(v); for (const shaderName of phase.shaders) { @@ -1070,7 +1070,7 @@ function buildLayoutGraphDataImpl (graph: LayoutGraph, builder: LayoutGraphBuild break; } default: - console.error('unknown vertex type'); + error('unknown vertex type'); minLevel = UpdateFrequency.PER_INSTANCE; minLevel = UpdateFrequency.PER_PASS; break; @@ -1092,7 +1092,7 @@ function buildLayoutGraphDataImpl (graph: LayoutGraph, builder: LayoutGraphBuild } const flattened = convertDescriptorBlock(block); if (block.capacity === 0) { - console.error('block capacity is 0'); + error('block capacity is 0'); return; } if (index.updateFrequency > UpdateFrequency.PER_BATCH) { @@ -1176,20 +1176,20 @@ class LayoutGraphBuilder2 { } addDescriptorBlock (nodeID: number, index: DescriptorBlockIndex, block: Readonly): void { if (block.capacity <= 0) { - console.error('empty block'); + error('empty block'); return; } if (block.descriptorNames.length !== block.descriptors.length) { - console.error('error descriptor'); + error('error descriptor'); return; } if (block.uniformBlockNames.length !== block.uniformBlocks.length) { - console.error('error uniform'); + error('error uniform'); return; } if (!(index.updateFrequency >= UpdateFrequency.PER_INSTANCE && index.updateFrequency <= UpdateFrequency.PER_PASS)) { - console.error('invalid update frequency'); + error('invalid update frequency'); return; } @@ -1230,7 +1230,7 @@ class LayoutGraphBuilder2 { } reserveDescriptorBlock (nodeID: number, index: DescriptorBlockIndex, block: DescriptorBlockFlattened): void { if (block.capacity <= 0) { - console.error('empty block'); + error('empty block'); return; } const g: LayoutGraphData = this.lg; @@ -1250,7 +1250,7 @@ class LayoutGraphBuilder2 { } } compile (): number { - // console.debug(this.print()); + // debug(this.print()); return 0; } print (): string { @@ -1435,7 +1435,7 @@ export function makeDescriptorSetLayoutData (lg: LayoutGraphData, // update uniform buffer binding const ub = uniformBlocks.get(d.descriptorID); if (!ub) { - console.error(`Uniform block not found for ${d.descriptorID}`); + error(`Uniform block not found for ${d.descriptorID}`); continue; } assert(ub.binding === 0xFFFFFFFF); @@ -1446,7 +1446,7 @@ export function makeDescriptorSetLayoutData (lg: LayoutGraphData, // update block capacity const binding = data.bindingMap.get(d.descriptorID); if (binding !== undefined) { - console.error(`Duplicated descriptor ${d.descriptorID}`); + error(`Duplicated descriptor ${d.descriptorID}`); } data.bindingMap.set(d.descriptorID, block.offset + block.capacity); block.capacity += d.count; @@ -1507,7 +1507,7 @@ export function initializeLayoutGraphData (device: Device, lg: LayoutGraphData): const layoutData = lg.getLayout(v); for (const [_, set] of layoutData.descriptorSets) { if (set.descriptorSetLayout !== null) { - console.warn('descriptor set layout already initialized. It will be overwritten'); + warn('descriptor set layout already initialized. It will be overwritten'); } initializeDescriptorSetLayoutInfo(set.descriptorSetLayoutData, set.descriptorSetLayoutInfo); @@ -1565,7 +1565,7 @@ export function getOrCreateDescriptorSetLayout (lg: LayoutGraphData, const data = phaseData.descriptorSets.get(rate); if (data) { if (!data.descriptorSetLayout) { - console.error('descriptor set layout not initialized'); + error('descriptor set layout not initialized'); return _emptyDescriptorSetLayout; } return data.descriptorSetLayout; @@ -1580,7 +1580,7 @@ export function getOrCreateDescriptorSetLayout (lg: LayoutGraphData, const data = passData.descriptorSets.get(rate); if (data) { if (!data.descriptorSetLayout) { - console.error('descriptor set layout not initialized'); + error('descriptor set layout not initialized'); return _emptyDescriptorSetLayout; } return data.descriptorSetLayout; @@ -1596,7 +1596,7 @@ export function getDescriptorSetLayout (lg: LayoutGraphData, const data = phaseData.descriptorSets.get(rate); if (data) { if (!data.descriptorSetLayout) { - console.error('descriptor set layout not initialized'); + error('descriptor set layout not initialized'); return null; } return data.descriptorSetLayout; @@ -1611,7 +1611,7 @@ export function getDescriptorSetLayout (lg: LayoutGraphData, const data = passData.descriptorSets.get(rate); if (data) { if (!data.descriptorSetLayout) { - console.error('descriptor set layout not initialized'); + error('descriptor set layout not initialized'); return null; } return data.descriptorSetLayout; diff --git a/cocos/rendering/custom/web-program-library.ts b/cocos/rendering/custom/web-program-library.ts index 35b9f691675..fa17cd734ee 100644 --- a/cocos/rendering/custom/web-program-library.ts +++ b/cocos/rendering/custom/web-program-library.ts @@ -33,7 +33,7 @@ import { ProgramLibrary, ProgramProxy } from './private'; import { DescriptorTypeOrder, UpdateFrequency } from './types'; import { ProgramGroup, ProgramInfo } from './web-types'; import { getCustomPassID, getCustomPhaseID, getOrCreateDescriptorSetLayout, getEmptyDescriptorSetLayout, getEmptyPipelineLayout, initializeDescriptorSetLayoutInfo, makeDescriptorSetLayoutData, getDescriptorSetLayout, getOrCreateDescriptorID, getDescriptorTypeOrder, getProgramID, getDescriptorNameID, getDescriptorName, INVALID_ID, ENABLE_SUBPASS, getCustomSubpassID } from './layout-graph-utils'; -import { assert } from '../../core/platform/debug'; +import { assert, error, warn } from '../../core/platform/debug'; import { IDescriptorSetLayoutInfo, localDescriptorSetLayout } from '../define'; import { PipelineRuntime } from './pipeline'; @@ -65,7 +65,7 @@ function overwriteProgramBlockInfo (shaderInfo: ShaderInfo, programInfo: IProgra } } if (!found) { - console.error(`Block ${block.name} not found in shader ${shaderInfo.name}`); + error(`Block ${block.name} not found in shader ${shaderInfo.name}`); } } } @@ -183,7 +183,7 @@ function populateMergedShaderInfo (valueNames: string[], for (const block of descriptorBlock.descriptors) { const uniformBlock = layout.uniformBlocks.get(block.descriptorID); if (uniformBlock === undefined) { - console.error(`Failed to find uniform block ${block.descriptorID} in layout`); + error(`Failed to find uniform block ${block.descriptorID} in layout`); continue; } blockSizes.push(getSize(uniformBlock.members)); @@ -195,7 +195,7 @@ function populateMergedShaderInfo (valueNames: string[], ++binding; } if (binding !== descriptorBlock.offset + descriptorBlock.capacity) { - console.error(`Uniform buffer binding mismatch for set ${set}`); + error(`Uniform buffer binding mismatch for set ${set}`); } break; case DescriptorTypeOrder.DYNAMIC_UNIFORM_BUFFER: @@ -319,7 +319,7 @@ function populateLocalShaderInfo ( const info = source.layouts[block.name] as UniformBlock | undefined; const binding = info && source.bindings.find((bd): boolean => bd.binding === info.binding); if (!info || !binding || !(binding.descriptorType & DESCRIPTOR_BUFFER_TYPE)) { - console.warn(`builtin UBO '${block.name}' not available!`); + warn(`builtin UBO '${block.name}' not available!`); continue; } blockSizes.push(getSize(block.members)); @@ -331,7 +331,7 @@ function populateLocalShaderInfo ( const info = source.layouts[samplerTexture.name] as UniformSamplerTexture; const binding = info && source.bindings.find((bd): boolean => bd.binding === info.binding); if (!info || !binding || !(binding.descriptorType & DESCRIPTOR_SAMPLER_TYPE)) { - console.warn(`builtin samplerTexture '${samplerTexture.name}' not available!`); + warn(`builtin samplerTexture '${samplerTexture.name}' not available!`); continue; } shaderInfo.samplerTextures.push(new UniformSamplerTexture( @@ -549,7 +549,7 @@ function getDescriptorNameAndType (source: IDescriptorSetLayoutInfo, binding: nu return [v.name, type]; } } - console.error('descriptor not found'); + error('descriptor not found'); return ['', Type.UNKNOWN]; } @@ -567,7 +567,7 @@ function makeLocalDescriptorSetLayoutData (lg: LayoutGraphData, data.descriptorBlocks.push(block); const binding = data.bindingMap.get(nameID); if (binding !== undefined) { - console.error(`duplicate descriptor name '${name}'`); + error(`duplicate descriptor name '${name}'`); } data.bindingMap.set(nameID, b.binding); const v = source.layouts[name]; @@ -601,7 +601,7 @@ function buildProgramData ( initializeDescriptorSetLayoutInfo(setData.descriptorSetLayoutData, setData.descriptorSetLayoutInfo); if (localDescriptorSetLayout.bindings.length !== setData.descriptorSetLayoutInfo.bindings.length) { - console.error('local descriptor set layout inconsistent'); + error('local descriptor set layout inconsistent'); } else { for (let k = 0; k !== localDescriptorSetLayout.bindings.length; ++k) { const b = localDescriptorSetLayout.bindings[k]; @@ -610,7 +610,7 @@ function buildProgramData ( || b.descriptorType !== b2.descriptorType || b.count !== b2.count || b.stageFlags !== b2.stageFlags) { - console.error('local descriptor set layout inconsistent'); + error('local descriptor set layout inconsistent'); } } } @@ -682,20 +682,20 @@ function getEffectShader (lg: LayoutGraphData, effect: EffectAsset, const programName = pass.program; const passID = getCustomPassID(lg, pass.pass); if (passID === INVALID_ID) { - console.error(`Invalid render pass, program: ${programName}`); + error(`Invalid render pass, program: ${programName}`); return [INVALID_ID, INVALID_ID, INVALID_ID, null, INVALID_ID]; } const enableSubpass = pass.subpass && pass.subpass !== '' && ENABLE_SUBPASS; const subpassID = enableSubpass ? getCustomSubpassID(lg, passID, pass.subpass!) : INVALID_ID; if (enableSubpass && subpassID === INVALID_ID) { - console.error(`Invalid render subpass, program: ${programName}`); + error(`Invalid render subpass, program: ${programName}`); return [INVALID_ID, INVALID_ID, INVALID_ID, null, INVALID_ID]; } const phaseID = getCustomPhaseID(lg, subpassID === INVALID_ID ? passID : subpassID, pass.phase); if (phaseID === INVALID_ID) { - console.error(`Invalid render phase, program: ${programName}`); + error(`Invalid render phase, program: ${programName}`); return [INVALID_ID, INVALID_ID, INVALID_ID, null, INVALID_ID]; } let srcShaderInfo: EffectAsset.IShaderInfo | null = null; @@ -715,7 +715,7 @@ function getEffectShader (lg: LayoutGraphData, effect: EffectAsset, function validateShaderInfo (srcShaderInfo: EffectAsset.IShaderInfo): number { // source shader info if (srcShaderInfo.descriptors === undefined) { - console.error(`No descriptors in shader: ${srcShaderInfo.name}, please reimport ALL effects`); + error(`No descriptors in shader: ${srcShaderInfo.name}, please reimport ALL effects`); return 1; } return 0; @@ -738,7 +738,7 @@ export class WebProgramLibrary implements ProgramLibrary { const programName = pass.program; const [passID, subpassID, phaseID, srcShaderInfo] = getEffectShader(lg, effect, pass); if (srcShaderInfo === null || validateShaderInfo(srcShaderInfo)) { - console.error(`program: ${programName} not found`); + error(`program: ${programName} not found`); continue; } assert(passID !== INVALID_ID && phaseID !== INVALID_ID); @@ -795,7 +795,7 @@ export class WebProgramLibrary implements ProgramLibrary { const programName = pass.program; const [passID, subpassID, phaseID, srcShaderInfo, shaderID] = getEffectShader(lg, effect, pass); if (srcShaderInfo === null || validateShaderInfo(srcShaderInfo)) { - console.error(`program: ${programName} not valid`); + error(`program: ${programName} not valid`); continue; } assert(passID !== INVALID_ID && phaseID !== INVALID_ID && shaderID !== INVALID_ID); @@ -833,13 +833,13 @@ export class WebProgramLibrary implements ProgramLibrary { // get phase const group = this.phases.get(phaseID); if (group === undefined) { - console.error(`Invalid render phase, program: ${programName}`); + error(`Invalid render phase, program: ${programName}`); return ''; } // get info const info = group.programInfos.get(programName); if (info === undefined) { - console.error(`Invalid program, program: ${programName}`); + error(`Invalid program, program: ${programName}`); return ''; } return getVariantKey(info.programInfo, defines); @@ -851,13 +851,13 @@ export class WebProgramLibrary implements ProgramLibrary { // get phase const group = this.phases.get(phaseID); if (group === undefined) { - console.error(`Invalid render phase, program: ${name}`); + error(`Invalid render phase, program: ${name}`); return null; } // get info const info = group.programInfos.get(name); if (info === undefined) { - console.error(`Invalid program, program: ${name}`); + error(`Invalid program, program: ${name}`); return null; } const programInfo = info.programInfo; @@ -882,7 +882,7 @@ export class WebProgramLibrary implements ProgramLibrary { if (deviceShaderVersion) { src = programInfo[deviceShaderVersion]; } else { - console.error('Invalid GFX API!'); + error('Invalid GFX API!'); } // prepare shader info @@ -927,12 +927,12 @@ export class WebProgramLibrary implements ProgramLibrary { assert(phaseID !== INVALID_ID); const group = this.phases.get(phaseID); if (!group) { - console.error(`Invalid render phase, program: ${programName}`); + error(`Invalid render phase, program: ${programName}`); return []; } const info = group.programInfos.get(programName); if (!info) { - console.error(`Invalid program, program: ${programName}`); + error(`Invalid program, program: ${programName}`); return []; } return info.blockSizes; @@ -942,12 +942,12 @@ export class WebProgramLibrary implements ProgramLibrary { assert(phaseID !== INVALID_ID); const group = this.phases.get(phaseID); if (!group) { - console.error(`Invalid render phase, program: ${programName}`); + error(`Invalid render phase, program: ${programName}`); return {}; } const info = group.programInfos.get(programName); if (!info) { - console.error(`Invalid program, program: ${programName}`); + error(`Invalid program, program: ${programName}`); return {}; } return info.handleMap; diff --git a/cocos/rendering/deferred/deferred-pipeline.ts b/cocos/rendering/deferred/deferred-pipeline.ts index eea6fe4fb8a..6850bd743dd 100644 --- a/cocos/rendering/deferred/deferred-pipeline.ts +++ b/cocos/rendering/deferred/deferred-pipeline.ts @@ -41,7 +41,7 @@ import { Format, StoreOp, TextureInfo, TextureType, TextureUsageBit, FramebufferInfo, Swapchain, GeneralBarrierInfo } from '../../gfx'; import { UBOGlobal, UBOCamera, UBOShadow, UNIFORM_SHADOWMAP_BINDING, UNIFORM_SPOT_SHADOW_MAP_TEXTURE_BINDING } from '../define'; import { Camera } from '../../render-scene/scene'; -import { errorID } from '../../core/platform/debug'; +import { errorID, log } from '../../core/platform/debug'; import { DeferredPipelineSceneData } from './deferred-pipeline-scene-data'; import { PipelineEventType } from '../pipeline-event'; @@ -84,7 +84,7 @@ export class DeferredPipeline extends RenderPipeline { public activate (swapchain: Swapchain): boolean { if (EDITOR) { - console.info('Deferred render pipeline initialized. ' + log('Deferred render pipeline initialized. ' + 'Note that non-transparent materials with no lighting will not be rendered, such as builtin-unlit.'); } diff --git a/cocos/rendering/forward/forward-pipeline.ts b/cocos/rendering/forward/forward-pipeline.ts index a8bdcaf1832..937ea6cbfce 100644 --- a/cocos/rendering/forward/forward-pipeline.ts +++ b/cocos/rendering/forward/forward-pipeline.ts @@ -33,7 +33,7 @@ import { Swapchain, RenderPass } from '../../gfx'; import { builtinResMgr } from '../../asset/asset-manager/builtin-res-mgr'; import { Texture2D } from '../../asset/assets/texture-2d'; import { Camera } from '../../render-scene/scene'; -import { errorID } from '../../core/platform/debug'; +import { errorID, log } from '../../core/platform/debug'; import { PipelineSceneData } from '../pipeline-scene-data'; import { ReflectionProbeFlow } from '../reflection-probe/reflection-probe-flow'; @@ -77,7 +77,7 @@ export class ForwardPipeline extends RenderPipeline { } public activate (swapchain: Swapchain): boolean { - if (EDITOR) { console.info('Forward render pipeline initialized.'); } + if (EDITOR) { log('Forward render pipeline initialized.'); } this._macros = { CC_PIPELINE_TYPE: PIPELINE_TYPE }; this._pipelineSceneData = new PipelineSceneData(); diff --git a/cocos/scene-graph/layers.ts b/cocos/scene-graph/layers.ts index c1ae357dec7..681e4f142cd 100644 --- a/cocos/scene-graph/layers.ts +++ b/cocos/scene-graph/layers.ts @@ -27,7 +27,7 @@ import { legacyCC } from '../core/global-exports'; import { log2 } from '../core/math/bits'; import { js } from '../core'; import { assertIsTrue } from '../core/data/utils/asserts'; -import { getError } from '../core/platform/debug'; +import { getError, warn } from '../core/platform/debug'; import { Settings, settings } from '../core/settings'; // built-in layers, users can use 0~19 bits, 20~31 are system preserve bits. @@ -118,11 +118,11 @@ export class Layers { */ public static addLayer (name: string, bitNum: number): void { if (bitNum === undefined) { - console.warn('bitNum can\'t be undefined'); + warn('bitNum can\'t be undefined'); return; } if (bitNum > 19 || bitNum < 0) { - console.warn('maximum layers reached.'); + warn('maximum layers reached.'); return; } const val = 1 << bitNum; @@ -143,7 +143,7 @@ export class Layers { */ public static deleteLayer (bitNum: number): void { if (bitNum > 19 || bitNum < 0) { - console.warn('do not change buildin layers.'); + warn('do not change builtin layers.'); return; } const val = 1 << bitNum; @@ -163,7 +163,7 @@ export class Layers { */ public static nameToLayer (name: string): number { if (name === undefined) { - console.warn('name can\'t be undefined'); + warn('name can\'t be undefined'); return -1; } @@ -177,7 +177,7 @@ export class Layers { */ public static layerToName (bitNum: number): string { if (bitNum > 31 || bitNum < 0) { - console.warn('Unable to access unknown layer.'); + warn('Unable to access unknown layer.'); return ''; } diff --git a/cocos/scene-graph/node-activator.ts b/cocos/scene-graph/node-activator.ts index 357a966057b..96e645a49f5 100644 --- a/cocos/scene-graph/node-activator.ts +++ b/cocos/scene-graph/node-activator.ts @@ -28,7 +28,7 @@ import { array, Pool } from '../core/utils/js'; import { tryCatchFunctor_EDITOR } from '../core/utils/misc'; import { invokeOnEnable, createInvokeImpl, createInvokeImplJit, OneOffInvoker, LifeCycleInvoker } from './component-scheduler'; import { legacyCC } from '../core/global-exports'; -import { assert, errorID, getError } from '../core/platform/debug'; +import { assert, errorID, getError, log } from '../core/platform/debug'; import { NodeEventType } from './node-event'; import { assertIsTrue } from '../core/data/utils/asserts'; import type { Component } from './component'; @@ -116,7 +116,7 @@ activateTasksPool.get = function getActivateTask (): ActivateTask { function _componentCorrupted (node: Node, comp: Component, index: number): void { errorID(3817, node.name, index); - console.log('Corrupted component value:', comp); + log('Corrupted component value:', comp); if (comp) { node._removeComponent(comp); } else { diff --git a/cocos/scene-graph/node-dev.ts b/cocos/scene-graph/node-dev.ts index cae8b7f732f..6515b71886e 100644 --- a/cocos/scene-graph/node-dev.ts +++ b/cocos/scene-graph/node-dev.ts @@ -26,7 +26,7 @@ import { EDITOR, DEV, TEST } from 'internal:constants'; import { CCObject } from '../core/data/object'; import * as js from '../core/utils/js'; import { legacyCC } from '../core/global-exports'; -import { error, errorID, getError } from '../core/platform/debug'; +import { error, errorID, getError, warn } from '../core/platform/debug'; import { Component } from './component'; const Destroying = CCObject.Flags.Destroying; @@ -147,7 +147,7 @@ export function nodePolyfill (Node): void { Node.prototype._registerIfAttached = function (register): void { if (!this._id) { - console.warn(`Node(${this && this.name}}) is invalid or its data is corrupted.`); + warn(`Node(${this && this.name}}) is invalid or its data is corrupted.`); return; } if (EditorExtends.Node && EditorExtends.Component) { @@ -157,7 +157,7 @@ export function nodePolyfill (Node): void { for (let i = 0; i < this._components.length; i++) { const comp = this._components[i]; if (!comp || !comp._id) { - console.warn(`Component attached to node:${this.name} is corrupted`); + warn(`Component attached to node:${this.name} is corrupted`); } else { EditorExtends.Component.add(comp._id, comp); } @@ -166,7 +166,7 @@ export function nodePolyfill (Node): void { for (let i = 0; i < this._components.length; i++) { const comp = this._components[i]; if (!comp || !comp._id) { - console.warn(`Component attached to node:${this.name} is corrupted`); + warn(`Component attached to node:${this.name} is corrupted`); } else { EditorExtends.Component.remove(comp._id); } diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index 53feee0935c..e7b44a7c6b8 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -656,9 +656,9 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { * @example * ``` * node.walk(function (target) { - * console.log('Walked through node ' + target.name + ' for the first time'); + * log('Walked through node ' + target.name + ' for the first time'); * }, function (target) { - * console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + * log('Walked through node ' + target.name + ' after walked all children in its sub tree'); * }); * ``` */ diff --git a/cocos/serialization/instantiate-jit.ts b/cocos/serialization/instantiate-jit.ts index e2edc54e7fb..a05cb0a7699 100644 --- a/cocos/serialization/instantiate-jit.ts +++ b/cocos/serialization/instantiate-jit.ts @@ -224,7 +224,7 @@ class Parser { this.result = Function('O', 'F', code)(this.objs, this.funcs); // if (TEST && !isPhantomJS) { - // console.log(code); + // log(code); // } // cleanup diff --git a/cocos/tiledmap/tiled-map.ts b/cocos/tiledmap/tiled-map.ts index 1c874976990..f543da4ab10 100644 --- a/cocos/tiledmap/tiled-map.ts +++ b/cocos/tiledmap/tiled-map.ts @@ -34,7 +34,7 @@ import { TiledObjectGroup } from './tiled-object-group'; import { TiledMapAsset } from './tiled-map-asset'; import { Sprite } from '../2d/components/sprite'; import { fillTextureGrids } from './tiled-utils'; -import { Size, Vec2, logID, Color, sys } from '../core'; +import { Size, Vec2, logID, Color, sys, warn } from '../core'; import { SpriteFrame } from '../2d/assets'; import { NodeEventType } from '../scene-graph/node-event'; import { Node } from '../scene-graph'; @@ -455,7 +455,7 @@ export class TiledMap extends Component { const tilesetInfo = tilesets[i]; if (!tilesetInfo) continue; if (!tilesetInfo.sourceImage) { - console.warn(`Can't find the spriteFrame of tilesets ${i}`); + warn(`Can't find the spriteFrame of tilesets ${i}`); continue; } fillTextureGrids(tilesetInfo, texGrids, tilesetInfo.sourceImage); diff --git a/cocos/tiledmap/tmx-xml-parser.ts b/cocos/tiledmap/tmx-xml-parser.ts index 79669a6b51a..f66e8d37974 100644 --- a/cocos/tiledmap/tmx-xml-parser.ts +++ b/cocos/tiledmap/tmx-xml-parser.ts @@ -30,7 +30,7 @@ import { GID, MixedGID, Orientation, PropertiesInfo, RenderOrder, StaggerAxis, StaggerIndex, TiledAnimation, TiledAnimationType, TileFlag, TMXImageLayerInfo, TMXLayerInfo, TMXObject, TMXObjectGroupInfo, TMXObjectType, TMXTilesetInfo, } from './tiled-types'; -import { Color, errorID, logID, Size, Vec2 } from '../core'; +import { Color, error, errorID, logID, Size, Vec2, warn } from '../core'; import { SpriteFrame } from '../2d/assets'; function uint8ArrayToUint32Array (uint8Arr: Uint8Array): null | Uint32Array | number[] { @@ -675,9 +675,9 @@ export class TMXMapInfo { tileset.imageName = shortName; tileset.sourceImage = this._spriteFrameMap![shortName]; if (!tileset.sourceImage) { - console.error(`[error]: ${shortName} not find in [${Object.keys(this._spriteFrameMap!).join(', ')}]`); + error(`[error]: ${shortName} not find in [${Object.keys(this._spriteFrameMap!).join(', ')}]`); errorID(7221, curImageName); - console.warn(`Please try asset type of ${curImageName} to 'sprite-frame'`); + warn(`Please try asset type of ${curImageName} to 'sprite-frame'`); } } } @@ -730,7 +730,7 @@ export class TMXMapInfo { tileset.sourceImage = this._spriteFrameMap![shortName]; if (!tileset.sourceImage) { errorID(7221, imageName); - console.warn(`Please try asset type of ${imageName} to 'sprite-frame'`); + warn(`Please try asset type of ${imageName} to 'sprite-frame'`); } } } @@ -818,7 +818,7 @@ export class TMXMapInfo { if (!imageLayer.sourceImage) { errorID(7221, source!); - console.warn(`Please try asset type of ${source} to 'sprite-frame'`); + warn(`Please try asset type of ${source} to 'sprite-frame'`); return null; } return imageLayer; diff --git a/cocos/tween/tween.ts b/cocos/tween/tween.ts index dfaca346899..3beb6574466 100644 --- a/cocos/tween/tween.ts +++ b/cocos/tween/tween.ts @@ -50,7 +50,7 @@ type ConstructorType = OmitType; * @example * tween(this.node) * .to(1, {scale: new Vec3(2, 2, 2), position: new Vec3(5, 5, 5)}) - * .call(() => { console.log('This is a callback'); }) + * .call(() => { log('This is a callback'); }) * .by(1, {scale: new Vec3(-1, -1, -1), position: new Vec3(-5, -5, -5)}, {easing: 'sineOutIn'}) * .start() */ @@ -487,7 +487,7 @@ legacyCC.Tween = Tween; * @example * tween(this.node) * .to(1, {scale: new Vec3(2, 2, 2), position: new Vec3(5, 5, 5)}) - * .call(() => { console.log('This is a callback'); }) + * .call(() => { log('This is a callback'); }) * .by(1, {scale: new Vec3(-1, -1, -1)}, {easing: 'sineOutIn'}) * .start() */ diff --git a/cocos/webgpu/instantiated.ts b/cocos/webgpu/instantiated.ts index baef8832445..fe96a4b212f 100644 --- a/cocos/webgpu/instantiated.ts +++ b/cocos/webgpu/instantiated.ts @@ -34,6 +34,7 @@ import wasmDevice from 'external:emscripten/webgpu/webgpu_wasm.js'; import glslangLoader from 'external:emscripten/webgpu/glslang.js'; import { legacyCC } from '../core/global-exports'; import { WebAssemblySupportMode } from '../misc/webassembly-support'; +import { log } from 'console'; export const glslalgWasmModule: any = { glslang: null, @@ -72,7 +73,7 @@ export const promiseForWebGPUInstantiation = (() => { adapter.requestDevice().then((device) => { webgpuAdapter.adapter = adapter; webgpuAdapter.device = device; - console.log(gfx); + log(gfx); resolve(); }); });