Comments (4)
This gives me another question:
I add my ILogger to my provider by using .AddLogging(builder => builder.AddConsole())
(for testing etc.).
Then I register Lavalink-related stuff using:
.AddSingleton<IAudioService, LavalinkNode>()
.AddSingleton<IDiscordClientWrapper, DiscordClientWrapper>()
.AddSingleton(new LavalinkNodeOptions
{
RestUri = "http://lavalink:8080/",
WebSocketUri = "ws://lavalink:8080/",
Password = "youshallnotpass",
AllowResuming = false // (btw, I can pause/resume despite this setting)
})
.AddSingleton<InactivityTrackingOptions>() // This is new
.AddSingleton<InactivityTrackingService>() // This is new, too
So my question is: How do I get the logger to the LavalinkNode instance when using DI?
Offtopic:
By the way, good work on this library! I enjoy working with it.
from lavalink4net.
The problem is with Dependency Injection, for example when creating the instance of InactivityTrackingService using its constructor the issue is solved, I added to the 1.3.0-release milestone adding service provider constructors (or constructors without the optional parameters) for use with dependency injection.
As a "work-around" you could use the constructor of the InactivityTrackingService to avoid the ILogger as shown below:
new ServiceCollection()
// [...] adding client wrapper, etc.
.AddSingleton(sp => new InactivityTrackingService(sp.GetRequiredService<IAudioService>(),
sp.GetRequiredService<IDiscordClientWrapper>(),
sp.GetRequiredService<InactivityTrackingOptions>(),
null))
// [...]
.BuildServiceProvider();
from lavalink4net.
This gives me another question:
I add my ILogger to my provider by using.AddLogging(builder => builder.AddConsole())
(for testing etc.).Then I register Lavalink-related stuff using:
.AddSingleton<IAudioService, LavalinkNode>() .AddSingleton<IDiscordClientWrapper, DiscordClientWrapper>() .AddSingleton(new LavalinkNodeOptions { RestUri = "http://lavalink:8080/", WebSocketUri = "ws://lavalink:8080/", Password = "youshallnotpass", AllowResuming = false // (btw, I can pause/resume despite this setting) }) .AddSingleton<InactivityTrackingOptions>() // This is new .AddSingleton<InactivityTrackingService>() // This is new, too
So my question is: How do I get the logger to the LavalinkNode instance when using DI?
Offtopic:
By the way, good work on this library! I enjoy working with it.
The ILogger-interface used by Lavalink4NET is not from Microsoft.Extensions.Logging(.Abstractions) anymore (since version 1.2.0, to remove the dependency).
See: https://github.com/angelobreuer/Lavalink4NET/blob/master/samples/Lavalink4NET.Discord_NET.ExampleBot/CustomLogger.cs for an example implementation of the interface. (It must be also added to the dependency injection service provider)
By the way:
AllowResuming = false // (btw, I can pause/resume despite this setting)
A note on this setting, this setting enables the session resume after reconnecting to the lavalink node to keep the player data (enqueued songs, etc.). Disabling the option will disconnect all players when stopping the bot.
from lavalink4net.
Hope the issue is fixed now with #8, release version 1.3.0 is now available (also on NuGet).
from lavalink4net.
Related Issues (20)
- TrackEncoder.Encode broken HOT 6
- ArtworkProvider doesn't work properly for SoundCloud tracks HOT 1
- Allow looping of the queue. HOT 7
- Lavalink4NET.DiscordNet.GetChannelUsersAsync doesn't work HOT 6
- [Bug?] TrackEnd fires multiple times at once. [Question] Using rest instead of websocket? HOT 4
- REST API Support HOT 13
- Lavalink4NET.DSharpPlus 3.0.0 seems to be incompatible with DSharpPlus versions above 4.3.0 HOT 2
- LoadTracksAsync null reference exception
- IPlayerManager.RetrieveAsync completely locks up HOT 6
- Bug: Player parameters not taken into account. HOT 3
- LavalinkNode does not recover from an unexpected websocket terminaison HOT 1
- Inactivity tracking notifications not called HOT 2
- DisposeAsyncCore seems to get fired multiple times HOT 4
- Skipping track with an empty queue always adds a `TrackQueueItem` to the history, rather than the actual item that was played HOT 4
- "Player stopped" status when trying to play music / Player not playing anything when using YouTube as a source HOT 5
- Error when trying to get the player using Discord.Net HOT 3
- Allow extending LavalinkClusterNode HOT 1
- Allow retrieving info about player' cluster HOT 3
- Allow to store additional info along with track HOT 2
- Allow to create user defined LavalinkTrack HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lavalink4net.