From 0c9e861caa8b1eed5068942edc35d5f91bac816e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 10 May 2012 06:24:07 +0000 Subject: Work towards translatable strings and a cleaner log interface. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4338 a436a847-0d15-0410-975c-d299462d15a1 --- src/socket/Socket.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/socket') diff --git a/src/socket/Socket.cpp b/src/socket/Socket.cpp index daeb6fa2..9c2a050c 100644 --- a/src/socket/Socket.cpp +++ b/src/socket/Socket.cpp @@ -29,7 +29,7 @@ #include "Socket.hpp" -#define LOG(s) s << "[Socket] " +#define LOG(s) (s("[Socket] ")) namespace Ingen { namespace Socket { @@ -96,8 +96,8 @@ Socket::set_addr(const std::string& uri) struct addrinfo* ainfo; int st = 0; if ((st = getaddrinfo(host.c_str(), port.c_str(), NULL, &ainfo))) { - LOG(Raul::error) << "Error in getaddrinfo: " - << gai_strerror(st) << std::endl; + LOG(Raul::error)(Raul::fmt("Error in getaddrinfo: %1%\n") + % gai_strerror(st)); return false; } @@ -117,8 +117,8 @@ Socket::bind(const std::string& uri) return true; } - LOG(Raul::error) << "Failed to bind " << _uri - << ": " << strerror(errno) << std::endl; + LOG(Raul::error)(Raul::fmt("Failed to bind <%1%> (%2%)\n") + % _uri % strerror(errno)); return false; } @@ -129,8 +129,8 @@ Socket::connect(const std::string& uri) return true; } - LOG(Raul::error) << "Failed to connect " << _uri - << ": " << strerror(errno) << std::endl; + LOG(Raul::error)(Raul::fmt("Failed to connect <%1%> (%2%)\n") + % _uri % strerror(errno)); return false; } @@ -138,10 +138,10 @@ bool Socket::listen() { if (::listen(_sock, 64) == -1) { - LOG(Raul::error) << "Failed to listen on " << _uri << std::endl; + LOG(Raul::error)(Raul::fmt("Failed to listen on %1%\n") % _uri); return false; } else { - LOG(Raul::info) << "Listening on " << _uri << std::endl; + LOG(Raul::info)(Raul::fmt("Listening on %1%\n") % _uri); return true; } } @@ -155,8 +155,8 @@ Socket::accept() int conn = ::accept(_sock, client_addr, &client_addr_len); if (conn == -1) { - LOG(Raul::error) << "Error accepting connection: " - << strerror(errno) << std::endl; + LOG(Raul::error)(Raul::fmt("Error accepting connection: %1%\n") + % strerror(errno)); return SharedPtr(); } -- cgit v1.2.1