Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
be1e774
[core] New implementation for the logging/formatting system
ethouris May 24, 2024
308af58
Fixed parts in non-default-enabled code parts
ethouris May 24, 2024
5ae2a03
Updated sfmt.h with reimplementation fixes
ethouris May 25, 2024
089dd51
Fixed heavy logging cases and atomics. Withdrawn changes for enums. U…
ethouris May 25, 2024
e37d37d
Provided a special version for atomic. Withdrawn unnecessary changes
ethouris May 26, 2024
6ce84fe
Changed more formatting usage to sfmt
ethouris May 26, 2024
8126c49
Removed ostringstream from utilities
ethouris May 26, 2024
216c1ed
Removed ostringstream use. Fixed C++03 problem with Ensure declaration
May 27, 2024
d8cebcd
Cleared out warn-errors for logging-off version
May 27, 2024
4e39fd7
Moved Printable out of C++11-dependent section (args... no longer nee…
May 27, 2024
5199746
Added extra version of snprintf for old Windows
ethouris May 27, 2024
4843143
Fixed the use of std::atomic
ethouris May 28, 2024
1a0eca4
Fixed the right atomic type used with logging. Fixed some reported sh…
ethouris May 28, 2024
9643702
Fixed a clang-reported warning (to trigger rebuilding)
ethouris May 28, 2024
f4ecbc1
Updated sfmt.h, fixed sync formatting
Jun 17, 2024
b90f540
Updated and merged
Jun 17, 2024
7660e92
Merge branch 'master' into dev-add-sfmt-for-logging
Jun 18, 2024
0a607c7
Some cosmetic fixes. Fixed the use of std::abs
Jun 18, 2024
d2ec1cf
Fixed usage of <cmath> with std
Jun 19, 2024
193fe39
Fixed correct includes for std::div
Jun 19, 2024
c81d4d6
Renamed sfmt.h and moved to srt namespace
Jun 20, 2024
0920fbf
[core] Setting up fmt with iomanip for logging system
Jun 25, 2024
f4088e4
Removed the use of sfmt obufstream
Jun 25, 2024
e48a6cb
Removed named reference to avoid dangling ref warning
Jun 25, 2024
2ba12a0
Added lacking include for sstream
Jun 25, 2024
f16fed7
Cleaned up previous usage of sfmt facilities
Jun 26, 2024
a49bdd9
Provided C++03 version of fmt
Jun 27, 2024
8b4d44c
Added some fixes as attempt to compile in C++03 (failed)
Jul 11, 2024
eed8c3f
Added separate C++03 compatible fmt API
Jul 18, 2024
4b6c56e
Removed commented-out previous code
Jul 18, 2024
e1617ea
Removed commented-out code
Jul 18, 2024
ac3d5d5
Moved overloaded operator << to inside the class
Jul 18, 2024
d1ae64d
Added C++11 flag that could be handled also on Windows
Jul 19, 2024
7472f05
Attempting to force C++11 in MICROSOFT to compile tools
Jul 19, 2024
4acdf00
Changed the way to require C++11 in apps.
Jul 19, 2024
d8bda01
Blocked unused function reported as warn/error
Jul 19, 2024
d0f472f
Merge branch 'master' into dev-add-custom-fmt-for-logging
Jul 22, 2024
061ec3b
Added UDL for fmt_stringview to simplify raw string format passing
Jul 22, 2024
1a6ce38
Added some more fixes with use of ofmt
Jul 23, 2024
05b5bb7
[maint] Removed VC 2013. Added VC 2022
Jul 25, 2024
a8664d2
Merge branch 'main-ci-remove-old-windows' into dev-add-custom-fmt-for…
Jul 26, 2024
880fa9d
Reworked the fmt API
Jul 26, 2024
fecce73
Updated and fixed
Sep 3, 2024
51350b1
Removed copyright notice blindly copied from another project
Sep 3, 2024
f0bfba8
Added more replacement for stringstream. Removed unused CIPAddress::show
Sep 11, 2024
8f82530
Updated and fixed
Sep 24, 2024
6106607
Merge branch 'master' into dev-add-custom-fmt-for-logging
ethouris Sep 24, 2024
a8dbce8
Merge branch 'master' into dev-add-custom-fmt-for-logging
Oct 18, 2024
59435c2
Merge branch 'master' into dev-add-custom-fmt-for-logging
Dec 6, 2024
d1e968c
Applied some parallel fixes from other PR
Feb 25, 2025
facc4ad
Merge branch 'master' into dev-add-custom-fmt-for-logging
Feb 25, 2025
99ca9b4
Updated and fixed
Feb 26, 2025
b956d8d
Added lacking file. Fixed wrong dependency on stdint
Feb 28, 2025
3f48500
Added changes for put_time
Mar 21, 2025
cfa02b5
Updated to latest dev
Aug 8, 2025
3e4ab20
Renamed ofmtstream to ofmtbufstream. Added ofmtrefstream. Some cosmetics
Aug 8, 2025
f36830b
Updated to dev and fixed
Aug 14, 2025
df805b2
Added a single-argument overload for fmt for simple use of iomanips
Aug 14, 2025
51c2e30
Changed the tm/put_time application for ofmt
Aug 14, 2025
bdbc76f
Cosmetics
Aug 21, 2025
8e33a80
Updated to latest dev and fixed
Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ script:
CMAKE_OPTS="-DENABLE_UNITTESTS=ON"
fi
- cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE $BUILD_OPTS $CMAKE_OPTS; then echo "Configure OK"; else cat CMakeFiles/CMakeError.log; fi;
- make -j$(nproc);
- make VERBOSE=1 -j$(nproc);
- if [ "$TRAVIS_COMPILER" != "x86_64-w64-mingw32-g++" ]; then
ulimit -c unlimited;
./test-srt -disable-ipv6;
Expand Down
6 changes: 3 additions & 3 deletions apps/apputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <chrono>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <memory>

Expand All @@ -21,6 +20,7 @@
#include "apputil.hpp"
#include "netinet_any.h"
#include "srt_compat.h"
#include "ofmt.h"

using namespace std;
using namespace srt;
Expand Down Expand Up @@ -145,10 +145,10 @@ sockaddr_any CreateAddr(const string& name, unsigned short port, int pref_family

string Join(const vector<string>& in, string sep)
{
if ( in.empty() )
if (in.empty())
return "";

ostringstream os;
srt::ofmtbufstream os;

os << in[0];
for (auto i = in.begin()+1; i != in.end(); ++i)
Expand Down
3 changes: 2 additions & 1 deletion apps/logsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "logsupport.hpp"
#include "../srtcore/srt.h"
#include "../srtcore/utilities.h"
#include "../srtcore/ofmt.h"

using namespace std;
using namespace srt;
Expand Down Expand Up @@ -174,7 +175,7 @@ set<srt_logging::LogFA> SrtParseLogFA(string fa, set<string>* punknown)

void ParseLogFASpec(const vector<string>& speclist, string& w_on, string& w_off)
{
std::ostringstream son, soff;
srt::ofmtbufstream son, soff;

for (auto& s: speclist)
{
Expand Down
6 changes: 4 additions & 2 deletions apps/srt-file-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,10 @@ bool DoUpload(UriParser& ut, string path, string filename,
while (n > 0)
{
int st = tar->Write(buf.data() + shift, n, 0, out_stats);
Verb() << "Upload: " << n << " --> " << st
<< (!shift ? string() : "+" + Sprint(shift));
Verb("Upload: ", n, " --> ", st, VerbNoEOL);
if (shift)
Verb("+", shift, VerbNoEOL);
Verb();
if (st == int(SRT_ERROR))
{
cerr << "Upload: SRT error: " << srt_getlasterror_str()
Expand Down
4 changes: 2 additions & 2 deletions apps/srt-tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@ class SrtMedium: public Medium
{
string message = srt_strerror(srterror, errnov);

string hm = srt::Sprint("ERROR #", srterror, ": ", text, ": ", message);
string hm = fmtcat("ERROR #", srterror, ": ", text, ": ", message);
if (errnov == 0)
throw TransmissionError(hm);
else
{
char buf[180];
throw TransmissionError(srt::Sprint(hm, ": #", errnov, ": ", SysStrError(errnov, buf, 179)));
throw TransmissionError(fmtcat(hm, ": #", errnov, ": ", SysStrError(errnov, buf, 179)));
}
}

Expand Down
17 changes: 9 additions & 8 deletions apps/transmitmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#include <sys/filio.h>
#endif

#define REQUIRE_CXX11 1

#include "srt_attr_defs.h"
#include "netinet_any.h"
#include "ofmt.h"
#include "apputil.hpp"
#include "socketoptions.hpp"
#include "uriparser.hpp"
Expand Down Expand Up @@ -230,9 +234,9 @@ void SrtCommon::InitParameters(string host, map<string,string> par)
&& transmit_chunk_size > SRT_LIVE_DEF_PLSIZE)
{
if (transmit_chunk_size > max_payload_size)
Error(Sprint("Chunk size in live mode exceeds ", max_payload_size, " bytes; this is not supported"));
Error(fmtcat("Chunk size in live mode exceeds ", max_payload_size, " bytes; this is not supported"));

par["payloadsize"] = Sprint(transmit_chunk_size);
par["payloadsize"] = fmts(transmit_chunk_size);
}
else
{
Expand Down Expand Up @@ -315,7 +319,7 @@ bool SrtCommon::AcceptNewClient()
{
srt_close(m_bindsock);
srt_close(m_sock);
Error(Sprint("accepted connection's payload size ", maxsize, " is too small for required ", transmit_chunk_size, " chunk size"));
Error(fmtcat("accepted connection's payload size ", maxsize, " is too small for required ", transmit_chunk_size, " chunk size"));
}

// we do one client connection at a time,
Expand Down Expand Up @@ -495,7 +499,7 @@ void SrtCommon::ConnectClient(string host, int port)
if (m_transtype == SRTT_LIVE && transmit_chunk_size > size_t(maxsize))
{
srt_close(m_sock);
Error(Sprint("accepted connection's payload size ", maxsize, " is too small for required ", transmit_chunk_size, " chunk size"));
Error(fmtcat("accepted connection's payload size ", maxsize, " is too small for required ", transmit_chunk_size, " chunk size"));
}

SRTSTATUS stat = ConfigurePost(m_sock);
Expand Down Expand Up @@ -586,10 +590,7 @@ SrtCommon::~SrtCommon()
SrtSource::SrtSource(string host, int port, const map<string,string>& par)
{
Init(host, port, par, false);

ostringstream os;
os << host << ":" << port;
hostport_copy = os.str();
hostport_copy = fmtcat(host, ":"_V, port);
}

int SrtSource::Read(size_t chunk, MediaPacket& pkt, ostream &out_stats)
Expand Down
18 changes: 10 additions & 8 deletions apps/uriparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,46 @@ UriParser::~UriParser(void)

string UriParser::makeUri()
{
using namespace srt;

// Reassemble parts into the URI
string prefix = "";
if (m_proto != "")
{
prefix = m_proto + "://";
}

std::ostringstream out;
ofmtbufstream out;

out << prefix << m_host;
out.print(prefix, m_host);
if ((m_port == "" || m_port == "0") && m_expect == EXPECT_FILE)
{
// Do not add port
}
else
{
out << ":" << m_port;
out.print(":"_V, m_port);
}

if (m_path != "")
{
if (m_path[0] != '/')
out << "/";
out << m_path;
out.print("/"_V);
out.print(m_path);
}

if (!m_mapQuery.empty())
{
out << "?";
out.print("?"_V);

query_it i = m_mapQuery.begin();
for (;;)
{
out << i->first << "=" << i->second;
out.print(i->first, "="_V, i->second);
++i;
if (i == m_mapQuery.end())
break;
out << "&";
out.print("&"_V);
}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/verbose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef INC_SRT_VERBOSE_HPP
#define INC_SRT_VERBOSE_HPP

#include <iostream>
#include "ofmt_iostream.h"
#include "sync.h"

namespace Verbose
Expand Down
10 changes: 5 additions & 5 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ string CUDTUnited::CONID(SRTSOCKET sock)
if (int32_t(sock) <= 0) // embraces SRT_INVALID_SOCK, SRT_SOCKID_CONNREQ and illegal negative domain
return "";

std::ostringstream os;
ofmtbufstream os;
os << "@" << int(sock) << ":";
return os.str();
}
Expand Down Expand Up @@ -1732,7 +1732,7 @@ SRTSOCKET CUDTUnited::groupConnect(CUDTGroup* pg, SRT_SOCKGROUPCONFIG* targets,
for (size_t i = 0; i < g.m_config.size(); ++i)
{
HLOGC(aclog.Debug, log << "groupConnect: OPTION @" << sid << " #" << g.m_config[i].so);
error_reason = "group-derived option: #" + Sprint(g.m_config[i].so);
error_reason = fmtcat("group-derived option: #", g.m_config[i].so);
ns->core().setOpt(g.m_config[i].so, &g.m_config[i].value[0], (int)g.m_config[i].value.size());
}

Expand Down Expand Up @@ -4003,13 +4003,13 @@ bool CUDTUnited::updateListenerMux(CUDTSocket* s, const CUDTSocket* ls)
CMultiplexer& m = i->second;

#if ENABLE_HEAVY_LOGGING
ostringstream that_muxer;
ofmtbufstream that_muxer;
that_muxer << "id=" << m.id() << " addr=" << m.selfAddr().str();
#endif

if (m.selfAddr().hport() == port)
{
HLOGC(smlog.Debug, log << "updateListenerMux: reusing muxer: " << that_muxer.str());
HLOGC(smlog.Debug, log << "updateListenerMux: reusing muxer: " << that_muxer);
if (m.selfAddr().family() == s->m_PeerAddr.family())
{
mux = &m; // best match
Expand All @@ -4023,7 +4023,7 @@ bool CUDTUnited::updateListenerMux(CUDTSocket* s, const CUDTSocket* ls)
}
else
{
HLOGC(smlog.Debug, log << "updateListenerMux: SKIPPING muxer: " << that_muxer.str());
HLOGC(smlog.Debug, log << "updateListenerMux: SKIPPING muxer: " << that_muxer);
}
}

Expand Down
8 changes: 4 additions & 4 deletions srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ CRcvBuffer::InsertInfo CRcvBuffer::insert(CUnit* unit)
IF_RCVBUF_DEBUG(scoped_log.ss << " returns -2");
return InsertInfo(InsertInfo::BELATED);
}
IF_HEAVY_LOGGING(string debug_source = "insert %" + Sprint(seqno));
IF_HEAVY_LOGGING(string debug_source = fmtcat("insert %", seqno));

if (offset >= COff(capacity()))
{
Expand Down Expand Up @@ -510,7 +510,7 @@ std::pair<int, int> CRcvBuffer::dropUpTo(int32_t seqno)
}
if (!m_tsbpd.isEnabled() && m_bMessageAPI)
updateFirstReadableNonOrder();
IF_HEAVY_LOGGING(debugShowState(("drop %" + Sprint(seqno)).c_str()));
IF_HEAVY_LOGGING(debugShowState(fmtcat("drop %", seqno).c_str()));
return std::make_pair(iNumDropped, iNumDiscarded);
}

Expand Down Expand Up @@ -660,7 +660,7 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro
updateGapInfo();

IF_HEAVY_LOGGING(debugShowState(
("dropmsg off %" + Sprint(seqnolo) + " #" + Sprint(msgno)).c_str()));
("dropmsg off %" + fmts(seqnolo) + " #" + fmts(msgno)).c_str()));

if (needUpdateNonreadPos)
{
Expand All @@ -674,7 +674,7 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro
updateFirstReadableNonOrder();
}

IF_HEAVY_LOGGING(debugShowState(("dropmsg off %" + Sprint(seqnolo)).c_str()));
IF_HEAVY_LOGGING(debugShowState(("dropmsg off %" + fmts(seqnolo)).c_str()));
return iDropCnt;
}

Expand Down
3 changes: 2 additions & 1 deletion srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,8 @@ EReadStatus CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet) const
#endif

HLOGC(krlog.Debug,
log << CONID() << "NET ERROR: packet size=" << recv_size << " msg_flags=0x" << hex << msg_flags
log << CONID() << "NET ERROR: packet size=" << recv_size << " msg_flags=0x"
<< fmt(msg_flags, hex)
<< ", detected flags:" << flg.str());
#endif
status = RST_AGAIN;
Expand Down
18 changes: 9 additions & 9 deletions srtcore/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ void CIPAddress::pton(sockaddr_any& w_addr, const uint32_t ip[4], const sockaddr
}
else
{
LOGC(inlog.Error, log << "pton: IPE or net error: can't determine IPv4 carryover format: " << std::hex
<< peeraddr16[0] << ":"
<< peeraddr16[1] << ":"
<< peeraddr16[2] << ":"
<< peeraddr16[3] << ":"
<< peeraddr16[4] << ":"
<< peeraddr16[5] << ":"
<< peeraddr16[6] << ":"
<< peeraddr16[7] << std::dec);
#if ENABLE_LOGGING
ofmtbufstream peeraddr_form;
fmtc hex04 = fmtc().hex().fillzero().width(4);
peeraddr_form << fmt(peeraddr16[0], hex04);
for (int i = 1; i < 8; ++i)
peeraddr_form << ":" << fmt(peeraddr16[i], hex04);

LOGC(inlog.Error, log << "pton: IPE or net error: can't determine IPv4 carryover format: " << peeraddr_form);
#endif
*target_ipv4_addr = 0;
if (peer.family() != AF_INET)
{
Expand Down
Loading
Loading