mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-27 01:40:52 +01:00
Update logging
This commit is contained in:
parent
7bc6496a5e
commit
673fcd112c
@ -1,26 +1,44 @@
|
|||||||
export class NitroLogger
|
export class NitroLogger
|
||||||
{
|
{
|
||||||
public static DEBUG_ENABLED: boolean = false;
|
public static LOG_DEBUG: boolean = false;
|
||||||
|
public static LOG_WARN: boolean = false;
|
||||||
|
public static LOG_ERROR: boolean = false;
|
||||||
|
public static LOG_EVENTS: boolean = false;
|
||||||
|
public static LOG_PACKETS: boolean = false;
|
||||||
|
|
||||||
public static log(...messages: any[]): void
|
public static log(...messages: any[]): void
|
||||||
{
|
{
|
||||||
if(!this.DEBUG_ENABLED) return;
|
if(!this.LOG_DEBUG) return;
|
||||||
|
|
||||||
console.log(this.logPrefix(), ...messages);
|
console.log(this.logPrefix(), ...messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static warn(...messages: any[]): void
|
||||||
|
{
|
||||||
|
if(!this.LOG_WARN) return;
|
||||||
|
|
||||||
|
console.warn(this.logPrefix(), ...messages);
|
||||||
|
}
|
||||||
|
|
||||||
public static error(...messages: any[]): void
|
public static error(...messages: any[]): void
|
||||||
{
|
{
|
||||||
if(!this.DEBUG_ENABLED) return;
|
if(!this.LOG_ERROR) return;
|
||||||
|
|
||||||
console.error(this.logPrefix(), ...messages);
|
console.error(this.logPrefix(), ...messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static warn(...messages: any[]): void
|
public static events(...messages: any[]): void
|
||||||
{
|
{
|
||||||
if(!this.DEBUG_ENABLED) return;
|
if(!this.LOG_EVENTS) return;
|
||||||
|
|
||||||
console.warn(this.logPrefix(), ...messages);
|
console.log(this.logPrefix(), ...messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static packets(...messages: any[]): void
|
||||||
|
{
|
||||||
|
if(!this.LOG_PACKETS) return;
|
||||||
|
|
||||||
|
console.log(this.logPrefix(), ...messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static logPrefix(): string
|
private static logPrefix(): string
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { IDisposable, IEventDispatcher, INitroEvent, NitroConfiguration, NitroLogger } from '../../api';
|
import { IDisposable, IEventDispatcher, INitroEvent, NitroLogger } from '../../api';
|
||||||
import { Disposable } from './Disposable';
|
import { Disposable } from './Disposable';
|
||||||
|
|
||||||
export class EventDispatcher extends Disposable implements IEventDispatcher, IDisposable
|
export class EventDispatcher extends Disposable implements IEventDispatcher, IDisposable
|
||||||
@ -59,7 +59,7 @@ export class EventDispatcher extends Disposable implements IEventDispatcher, IDi
|
|||||||
{
|
{
|
||||||
if(!event) return false;
|
if(!event) return false;
|
||||||
|
|
||||||
if(NitroConfiguration.getValue<boolean>('system.dispatcher.log')) NitroLogger.log('Dispatched Event', event.type);
|
NitroLogger.events('Dispatched Event', event.type);
|
||||||
|
|
||||||
this.processEvent(event);
|
this.processEvent(event);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ICodec, ICommunicationManager, IConnection, IConnectionStateListener, IMessageComposer, IMessageConfiguration, IMessageDataWrapper, IMessageEvent, NitroConfiguration, NitroLogger, WebSocketEventEnum } from '../../api';
|
import { ICodec, ICommunicationManager, IConnection, IConnectionStateListener, IMessageComposer, IMessageConfiguration, IMessageDataWrapper, IMessageEvent, NitroLogger, WebSocketEventEnum } from '../../api';
|
||||||
import { SocketConnectionEvent } from '../../events';
|
import { SocketConnectionEvent } from '../../events';
|
||||||
import { EventDispatcher } from '../common';
|
import { EventDispatcher } from '../common';
|
||||||
import { EvaWireFormat } from './codec';
|
import { EvaWireFormat } from './codec';
|
||||||
@ -174,7 +174,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
if(header === -1)
|
if(header === -1)
|
||||||
{
|
{
|
||||||
if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('Unknown Composer', composer.constructor.name);
|
NitroLogger.packets('Unknown Composer', composer.constructor.name);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -184,12 +184,12 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
if(!encoded)
|
if(!encoded)
|
||||||
{
|
{
|
||||||
if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('Encoding Failed', composer.constructor.name);
|
NitroLogger.packets('Encoding Failed', composer.constructor.name);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('OutgoingComposer', header, composer.constructor.name, message);
|
NitroLogger.packets('OutgoingComposer', header, composer.constructor.name, message);
|
||||||
|
|
||||||
this.write(encoded.getBuffer());
|
this.write(encoded.getBuffer());
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
if(!messages || !messages.length) continue;
|
if(!messages || !messages.length) continue;
|
||||||
|
|
||||||
if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
|
NitroLogger.packets('IncomingMessage', wrapper.header, messages[0].constructor.name, messages[0].parser);
|
||||||
|
|
||||||
this.handleMessages(...messages);
|
this.handleMessages(...messages);
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
|||||||
|
|
||||||
if(!events || !events.length)
|
if(!events || !events.length)
|
||||||
{
|
{
|
||||||
if(NitroConfiguration.getValue<boolean>('system.packet.log')) NitroLogger.log('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
|
NitroLogger.packets('IncomingMessage', wrapper.header, 'UNREGISTERED', wrapper);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Application, IApplicationOptions } from '@pixi/app';
|
import { Application, IApplicationOptions } from '@pixi/app';
|
||||||
import { SCALE_MODES } from '@pixi/constants';
|
import { SCALE_MODES } from '@pixi/constants';
|
||||||
import { settings } from '@pixi/settings';
|
import { settings } from '@pixi/settings';
|
||||||
import { IAvatarRenderManager, IEventDispatcher, ILinkEventTracker, INitroCommunicationManager, INitroCore, INitroLocalizationManager, IRoomCameraWidgetManager, IRoomEngine, IRoomManager, IRoomSessionManager, ISessionDataManager, ISoundManager, NitroConfiguration } from '../api';
|
import { IAvatarRenderManager, IEventDispatcher, ILinkEventTracker, INitroCommunicationManager, INitroCore, INitroLocalizationManager, IRoomCameraWidgetManager, IRoomEngine, IRoomManager, IRoomSessionManager, ISessionDataManager, ISoundManager, NitroConfiguration, NitroLogger } from '../api';
|
||||||
import { ConfigurationEvent, EventDispatcher, NitroCore } from '../core';
|
import { ConfigurationEvent, EventDispatcher, NitroCore } from '../core';
|
||||||
import { NitroEvent, RoomEngineEvent } from '../events';
|
import { NitroEvent, RoomEngineEvent } from '../events';
|
||||||
import { GetTicker, PixiApplicationProxy } from '../pixi-proxy';
|
import { GetTicker, PixiApplicationProxy } from '../pixi-proxy';
|
||||||
@ -196,6 +196,12 @@ export class Nitro implements INitro
|
|||||||
const limitsFPS = NitroConfiguration.getValue<boolean>('system.limits.fps', false);
|
const limitsFPS = NitroConfiguration.getValue<boolean>('system.limits.fps', false);
|
||||||
|
|
||||||
if(limitsFPS) GetTicker().maxFPS = animationFPS;
|
if(limitsFPS) GetTicker().maxFPS = animationFPS;
|
||||||
|
|
||||||
|
NitroLogger.LOG_DEBUG = NitroConfiguration.getValue<boolean>('system.log.debug', true);
|
||||||
|
NitroLogger.LOG_WARN = NitroConfiguration.getValue<boolean>('system.log.warn', false);
|
||||||
|
NitroLogger.LOG_ERROR = NitroConfiguration.getValue<boolean>('system.log.error', false);
|
||||||
|
NitroLogger.LOG_EVENTS = NitroConfiguration.getValue<boolean>('system.log.events', false);
|
||||||
|
NitroLogger.LOG_PACKETS = NitroConfiguration.getValue<boolean>('system.log.packets', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRoomEngineReady(event: RoomEngineEvent): void
|
private onRoomEngineReady(event: RoomEngineEvent): void
|
||||||
|
Loading…
Reference in New Issue
Block a user