Closed NedcloarBR closed 2 months ago
wdym the logs are only ment to be turned on if smt isn't working so you don'T have to debug the internal code
I think, he means to create a debug event to send logs
Like:
client.lavalink.on("debug", (message) => console.log(message));
This makes not really sense for lavalink-client, i'd rather create a function on manager Options like internalLogging(module:"node"|"player"|"utils"|"manager"|"filters", { error: null|Error, info: string })
But ofc. i could also add an event, i'd call it not debug tho, maybe "internal" but also debug makes sense, i'm just thinking in a way that it's clear that it's only for the client, and not related to lavalink at all
It's a little bit related with the manager... But it would be a bit nice to have that event, but if you don't see it necessary, it's okay
I think, he means to create a debug event to send logs
Like:
client.lavalink.on("debug", (message) => console.log(message));
Yeah is that I think thats is useful for logging controll like users with custom logger just for styled terminal or functional custom loggers with transcript
I guess there is a good point in wanting to use some custom logger
Version 2.3.3 released
This introduces a first version of the debug event
I added a bunch of events
export enum DebugEvents {
SetSponsorBlock = "SetSponsorBlock",
DeleteSponsorBlock = "DeleteSponsorBlock",
TrackEndReplaced = "TrackEndReplaced",
AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
QueueEnded = "QueueEnded",
TrackStartNewSongsOnly = "TrackStartNewSongsOnly",
TrackStartNoTrack = "TrackStartNoTrack",
ResumingFetchingError = "ResumingFetchingError",
PlayerUpdateNoPlayer = "PlayerUpdateNoPlayer",
PlayerUpdateFilterFixApply = "PlayerUpdateFilterFixApply",
PlayerUpdateSuccess = "PlayerUpdateSuccess",
HeartBeatTriggered = "HeartBeatTriggered",
NoSocketOnDestroy = "NoSocketOnDestroy",
SocketTerminateHeartBeatTimeout = "SocketTerminateHeartBeatTimeout",
TryingConnectWhileConnected = "TryingConnectWhileConnected",
LavaSearchNothingFound = "LavaSearchNothingFound",
SearchNothingFound = "SearchNothingFound",
ValidatingBlacklistLinks = "ValidatingBlacklistLinks",
ValidatingWhitelistLinks = "ValidatingWhitelistLinks",
TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime",
PlayerDestroyingSomewhereElse = "PlayerDestroyingSomewhereElse",
PlayerCreateNodeNotFound = "PlayerCreateNodeNotFound",
PlayerPlayQueueEmptyTimeoutClear = "PlayerPlayQueueEmptyTimeoutClear",
PlayerPlayWithTrackReplace = "PlayerPlayWithTrackReplace",
PlayerPlayUnresolvedTrack = "PlayerPlayUnresolvedTrack",
PlayerPlayUnresolvedTrackFailed = "PlayerPlayUnresolvedTrackFailed",
PlayerVolumeAsFilter = "PlayerVolumeAsFilter",
BandcampSearchLokalEngine = "BandcampSearchLokalEngine",
PlayerChangeNode = "PlayerChangeNode",
BuildTrackError = "BuildTrackError",
TransformRequesterFunctionFailed = "TransformRequesterFunctionFailed",
GetClosestTrackFailed = "GetClosestTrackFailed",
PlayerDeleteInsteadOfDestroy = "PlayerDeleteInsteadOfDestroy",
FailedToConnectToNodes = "FailedToConnectToNodes",
NoAudioDebug = "NoAudioDebug",
PlayerAutoReconnect = "PlayerAutoReconnect"
}
This is how you can listen to them:
client.lavalink.on("debug", (eventKey, eventData) => {
// skip specific log
if(eventKey === DebugEvents.NoAudioDebug && eventData.message === "Manager is not initated yet") return;
// skip specific event log of a log-level-state "log"
if(eventKey === DebugEvents.PlayerUpdateSuccess && eventData.state === "log") return;
console.group("Lavalink-Client-Debug:");
console.log("-".repeat(20));
console.debug(`[${eventKey}]`);
console.debug(eventData)
console.log("-".repeat(20));
console.groupEnd();
});
Update Log:
this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime
:
{ threshold: number, maxAmount: number }
(set threshold to 0 or maxAmount to -1 to disable){ threshold: 10_000, maxAmount: 3 }
this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs
:
10_000
(default)0
to disableLavalinkManager#debug(event:DebugEvents, data:{ state: "log" | "warn" | "error", message:string, functionLayer:string, error?:Error })
true
: LavalinkManager.options.advancedOptions.enableDebugEvents
DebugEvents
Enum to listen to specific events and only show those you caredata.state
to only show the certain log-level statefunctionLayer
string will show you where the debug event was triggered frommessage
string will show what is debuggederror
object will show you the error that happened, if there was one.Please leave a review wether you like or not, feel free to add more debug logs via PR or suggestions by openign a ticket / messaging me on discord.
It took quite some time to setup just debug logs which i recommend to only use on a testing environment.
For handling the debug options instead of direct logging
also i can create a PR