|
4 | 4 | #include "Media/AsyncMediaPlayer.g.cpp" |
5 | 5 | #endif |
6 | 6 |
|
| 7 | +#include <string> |
| 8 | +#include <format> |
| 9 | + |
7 | 10 | #include <winrt/Windows.Foundation.Collections.h> |
| 11 | +#include <winrt/Telegram.Td.h> |
| 12 | +#include <winrt/Telegram.Td.Api.h> |
8 | 13 |
|
9 | 14 | namespace winrt::Telegram::Native::Media::implementation |
10 | 15 | { |
@@ -593,25 +598,25 @@ namespace winrt::Telegram::Native::Media::implementation |
593 | 598 |
|
594 | 599 | void AsyncMediaPlayer::HandleLog(int level, const libvlc_log_t* ctx, const char* fmt, va_list args) |
595 | 600 | { |
596 | | - if (m_log) |
597 | | - { |
598 | | - int byteLength = vsnprintf(nullptr, 0, fmt, args) + 1; |
599 | | - if (byteLength <= 1) |
600 | | - return; |
| 601 | + int byteLength = vsnprintf(nullptr, 0, fmt, args) + 1; |
| 602 | + if (byteLength <= 1) |
| 603 | + return; |
601 | 604 |
|
602 | | - char* buffer = new char[byteLength]; |
603 | | - vsprintf_s(buffer, byteLength, fmt, args); |
604 | | - hstring message = winrt::to_hstring(std::string(buffer, byteLength - 1)); |
605 | | - delete[] buffer; |
| 605 | + char* buffer = new char[byteLength]; |
| 606 | + vsprintf_s(buffer, byteLength, fmt, args); |
| 607 | + std::string message(buffer, byteLength - 1); |
| 608 | + delete[] buffer; |
606 | 609 |
|
607 | | - const char* module; |
608 | | - const char* file; |
609 | | - unsigned int line = 0; |
610 | | - libvlc_log_get_context(ctx, &module, &file, &line); |
| 610 | + const char* module; |
| 611 | + const char* file; |
| 612 | + unsigned int line = 0; |
| 613 | + libvlc_log_get_context(ctx, &module, &file, &line); |
611 | 614 |
|
612 | | - // TODO: |
613 | | - m_log(*this, AsyncMediaPlayerLogEventArgs((AsyncMediaPlayerLogLevel)level, message, winrt::to_hstring(module), winrt::to_hstring(file), line)); |
614 | | - } |
| 615 | + std::stringstream ss; |
| 616 | + ss << "[AsyncMediaPlayer.cpp][" << file << ":" << line << "][" << message; |
| 617 | + winrt::Telegram::Td::Client::Execute(winrt::Telegram::Td::Api::AddLogMessage(2, winrt::to_hstring(ss.str()))); |
| 618 | + |
| 619 | + m_log(*this, AsyncMediaPlayerLogEventArgs((AsyncMediaPlayerLogLevel)level, winrt::to_hstring(message), winrt::to_hstring(module), winrt::to_hstring(file), line)); |
615 | 620 | } |
616 | 621 |
|
617 | 622 | void AsyncMediaPlayer::HandleEvent(const libvlc_event_t* event) |
|
0 commit comments