log4cplus  2.1.0
Classes | Typedefs | Enumerations | Functions | Variables
log4cplus::helpers Namespace Reference

Classes

class  AppenderAttachableImpl
 This Interface is for attaching Appenders to objects. More...
 
class  IConnectorThreadClient
 Interface implemented by users of ConnectorThread. More...
 
class  ConnectorThread
 This class is used by SocketAppender and (remote) SysLogAppender to provide asynchronous re-connection. More...
 
struct  FileInfo
 FileInfo structure is OS independent abstraction of the stat() function. More...
 
class  LockFile
 
class  LogLog
 This class used to output log statements from within the log4cplus package. More...
 
class  SharedObject
 
class  SharedObjectPtr
 
class  Properties
 
class  snprintf_buf
 
class  AbstractSocket
 
class  Socket
 This class implements client sockets (also called just "sockets"). More...
 
class  ServerSocket
 This class implements server sockets. More...
 
class  SocketBuffer
 
struct  ConvertIntegerToStringHelper
 
struct  ConvertIntegerToStringHelper< intType, charType, true >
 
struct  ConvertIntegerToStringHelper< intType, charType, false >
 
struct  ADDRINFOT_deleter
 
struct  socket_closer
 
struct  socket_holder
 

Typedefs

typedef log4cplus::thread::SyncGuard< LockFileLockFileGuard
 
typedef std::ptrdiff_t SOCKET_TYPE
 
typedef chrono::system_clock Clock
 
typedef chrono::duration< long long, std::micro > Duration
 
typedef chrono::time_point< Clock, DurationTime
 
typedef SOCKET os_socket_type
 

Enumerations

enum  SocketState {
  ok , not_opened , bad_address , connection_failed ,
  broken_pipe , invalid_access_mode , message_truncated , accept_interrupted
}
 

Functions

LOG4CPLUS_EXPORT int getFileInfo (FileInfo *fi, tstring const &name)
 OS independent abstraction of stat() function. More...
 
LOG4CPLUS_EXPORT LogLoggetLogLog ()
 
LOG4CPLUS_EXPORT SOCKET_TYPE openSocket (unsigned short port, bool udp, bool ipv6, SocketState &state)
 
LOG4CPLUS_EXPORT SOCKET_TYPE openSocket (tstring const &host, unsigned short port, bool udp, bool ipv6, SocketState &state)
 
LOG4CPLUS_EXPORT SOCKET_TYPE connectSocket (const log4cplus::tstring &hostn, unsigned short port, bool udp, bool ipv6, SocketState &state)
 
LOG4CPLUS_EXPORT SOCKET_TYPE acceptSocket (SOCKET_TYPE sock, SocketState &state)
 
LOG4CPLUS_EXPORT int closeSocket (SOCKET_TYPE sock)
 
LOG4CPLUS_EXPORT int shutdownSocket (SOCKET_TYPE sock)
 
LOG4CPLUS_EXPORT long read (SOCKET_TYPE sock, SocketBuffer &buffer)
 
LOG4CPLUS_EXPORT long write (SOCKET_TYPE sock, const SocketBuffer &buffer)
 
LOG4CPLUS_EXPORT long write (SOCKET_TYPE sock, std::size_t bufferCount, SocketBuffer const *const *buffers)
 
LOG4CPLUS_EXPORT long write (SOCKET_TYPE sock, const std::string &buffer)
 
LOG4CPLUS_EXPORT tstring getHostname (bool fqdn)
 
LOG4CPLUS_EXPORT int setTCPNoDelay (SOCKET_TYPE, bool)
 
LOG4CPLUS_EXPORT log4cplus::tstring toUpper (const log4cplus::tstring &s)
 Returns s in upper case. More...
 
LOG4CPLUS_EXPORT tchar toUpper (tchar)
 
LOG4CPLUS_EXPORT log4cplus::tstring toLower (const log4cplus::tstring &s)
 Returns s in lower case. More...
 
LOG4CPLUS_EXPORT tchar toLower (tchar)
 
template<class StringType , class OutputIter >
void tokenize (const StringType &s, typename StringType::value_type c, OutputIter result, bool collapseTokens=true)
 Tokenize s using c as the delimiter and put the resulting tokens in _result. More...
 
template<class stringType , class intType >
void convertIntegerToString (stringType &str, intType value)
 
template<class intType >
tstring convertIntegerToString (intType value)
 
template<class intType >
std::string convertIntegerToNarrowString (intType value)
 
template<typename Iterator , typename Separator >
void join_worker (tstring &result, Iterator &start, Iterator &last, Separator const &sep)
 Join a list of items into a string. More...
 
template<typename Iterator >
void join (tstring &result, Iterator start, Iterator last, tstring const &sep)
 Join a list of items into a string. More...
 
template<typename Iterator >
void join (tstring &result, Iterator start, Iterator last, tstring::value_type sep)
 Join a list of items into a string. More...
 
template<typename FromDuration >
Time time_cast (chrono::time_point< Clock, FromDuration > const &tp)
 
Time now ()
 
Time from_time_t (time_t t_time)
 
time_t to_time_t (Time const &the_time)
 
LOG4CPLUS_EXPORT Time from_struct_tm (tm *t)
 
Time truncate_fractions (Time const &the_time)
 
long microseconds_part (Time const &the_time)
 
Time time_from_parts (time_t tv_sec, long tv_usec)
 
LOG4CPLUS_EXPORT void gmTime (tm *t, Time const &)
 Populates tm using the gmtime() function. More...
 
LOG4CPLUS_EXPORT void localTime (tm *t, Time const &)
 Populates tm using the localtime() function. More...
 
LOG4CPLUS_EXPORT log4cplus::tstring getFormattedTime (log4cplus::tstring const &fmt, Time const &the_time, bool use_gmtime=false)
 Returns a string with a "formatted time" specified by fmt. More...
 
static os_socket_type to_os_socket (SOCKET_TYPE const &x)
 
static SOCKET_TYPE to_log4cplus_socket (os_socket_type const &x)
 
static void set_last_socket_error (int err)
 
static int get_last_socket_error ()
 
LOG4CPLUS_EXPORT void convertToBuffer (SocketBuffer &buffer, const log4cplus::spi::InternalLoggingEvent &event, const log4cplus::tstring &serverName)
 
LOG4CPLUS_EXPORT log4cplus::spi::InternalLoggingEvent readFromBuffer (SocketBuffer &buffer)
 
std::string tostring (char const *str)
 
std::string tostring (std::string const &str)
 
std::string const & tostring (std::string &str)
 
std::string tostring (std::string &&str)
 
std::wstring towstring (wchar_t const *str)
 
std::wstring towstring (std::wstring const &str)
 
std::wstring const & towstring (std::wstring &str)
 
std::wstring towstring (std::wstring &&str)
 
LOG4CPLUS_EXPORT std::string tostring (const std::wstring &)
 
LOG4CPLUS_EXPORT std::string tostring (wchar_t const *)
 
LOG4CPLUS_EXPORT std::wstring towstring (const std::string &)
 
LOG4CPLUS_EXPORT std::wstring towstring (char const *)
 
void intrusive_ptr_add_ref (SharedObject const *so)
 Boost intrusive_ptr helpers. More...
 
void intrusive_ptr_release (SharedObject const *so)
 

Variables

class LOG4CPLUS_EXPORT ConnectorThread
 
LOG4CPLUS_EXPORT SOCKET_TYPE const INVALID_SOCKET_VALUE
 
os_socket_type const INVALID_OS_SOCKET_VALUE = INVALID_SOCKET
 

Typedef Documentation

◆ Clock

typedef chrono::system_clock log4cplus::helpers::Clock

Definition at line 52 of file timehelper.h.

◆ Duration

typedef chrono::duration<long long, std::micro> log4cplus::helpers::Duration

Definition at line 53 of file timehelper.h.

◆ LockFileGuard

Definition at line 63 of file lockfile.h.

◆ os_socket_type

Definition at line 74 of file internal/socket.h.

◆ SOCKET_TYPE

typedef std::ptrdiff_t log4cplus::helpers::SOCKET_TYPE

Definition at line 52 of file helpers/socket.h.

◆ Time

typedef chrono::time_point<Clock, Duration> log4cplus::helpers::Time

Definition at line 54 of file timehelper.h.

Enumeration Type Documentation

◆ SocketState

Enumerator
ok 
not_opened 
bad_address 
connection_failed 
broken_pipe 
invalid_access_mode 
message_truncated 
accept_interrupted 

Definition at line 42 of file helpers/socket.h.

Function Documentation

◆ acceptSocket()

LOG4CPLUS_EXPORT SOCKET_TYPE log4cplus::helpers::acceptSocket ( SOCKET_TYPE  sock,
SocketState state 
)

◆ closeSocket()

LOG4CPLUS_EXPORT int log4cplus::helpers::closeSocket ( SOCKET_TYPE  sock)

◆ connectSocket()

LOG4CPLUS_EXPORT SOCKET_TYPE log4cplus::helpers::connectSocket ( const log4cplus::tstring hostn,
unsigned short  port,
bool  udp,
bool  ipv6,
SocketState state 
)

◆ convertIntegerToNarrowString()

template<class intType >
std::string log4cplus::helpers::convertIntegerToNarrowString ( intType  value)
inline

Definition at line 221 of file stringhelper.h.

References convertIntegerToString().

◆ convertIntegerToString() [1/2]

template<class intType >
tstring log4cplus::helpers::convertIntegerToString ( intType  value)
inline

Definition at line 210 of file stringhelper.h.

References convertIntegerToString().

◆ convertIntegerToString() [2/2]

template<class stringType , class intType >
void log4cplus::helpers::convertIntegerToString ( stringType &  str,
intType  value 
)
inline

Definition at line 163 of file stringhelper.h.

References LOG4CPLUS_TEXT, and LOG4CPLUS_UNLIKELY.

Referenced by convertIntegerToNarrowString(), and convertIntegerToString().

◆ convertToBuffer()

LOG4CPLUS_EXPORT void log4cplus::helpers::convertToBuffer ( SocketBuffer buffer,
const log4cplus::spi::InternalLoggingEvent event,
const log4cplus::tstring serverName 
)

◆ from_struct_tm()

LOG4CPLUS_EXPORT Time log4cplus::helpers::from_struct_tm ( tm *  t)

◆ from_time_t()

Time log4cplus::helpers::from_time_t ( time_t  t_time)
inline

Definition at line 76 of file timehelper.h.

References time_cast().

Referenced by microseconds_part(), time_from_parts(), to_time_t(), and truncate_fractions().

◆ get_last_socket_error()

static int log4cplus::helpers::get_last_socket_error ( )
inlinestatic

Definition at line 208 of file internal/socket.h.

◆ getFileInfo()

LOG4CPLUS_EXPORT int log4cplus::helpers::getFileInfo ( FileInfo fi,
tstring const &  name 
)

OS independent abstraction of stat() function.

◆ getFormattedTime()

LOG4CPLUS_EXPORT log4cplus::tstring log4cplus::helpers::getFormattedTime ( log4cplus::tstring const &  fmt,
Time const &  the_time,
bool  use_gmtime = false 
)

Returns a string with a "formatted time" specified by fmt.

It used the strftime() function to do this.

Look at your platform's strftime() documentation for the formatting options available.

The following additional options are provided:
q - 3 character field that provides milliseconds Q - 7 character field that provides fractional milliseconds.

◆ getHostname()

LOG4CPLUS_EXPORT tstring log4cplus::helpers::getHostname ( bool  fqdn)

◆ getLogLog()

LOG4CPLUS_EXPORT LogLog& log4cplus::helpers::getLogLog ( )

◆ gmTime()

LOG4CPLUS_EXPORT void log4cplus::helpers::gmTime ( tm *  t,
Time const &   
)

Populates tm using the gmtime() function.

◆ intrusive_ptr_add_ref()

void log4cplus::helpers::intrusive_ptr_add_ref ( SharedObject const *  so)
inline

Boost intrusive_ptr helpers.

Definition at line 193 of file pointer.h.

References log4cplus::helpers::SharedObject::addReference().

◆ intrusive_ptr_release()

void log4cplus::helpers::intrusive_ptr_release ( SharedObject const *  so)
inline

Definition at line 200 of file pointer.h.

References log4cplus::helpers::SharedObject::removeReference().

◆ join() [1/2]

template<typename Iterator >
void log4cplus::helpers::join ( tstring result,
Iterator  start,
Iterator  last,
tstring const &  sep 
)
inline

Join a list of items into a string.

Definition at line 250 of file stringhelper.h.

References join_worker().

◆ join() [2/2]

template<typename Iterator >
void log4cplus::helpers::join ( tstring result,
Iterator  start,
Iterator  last,
tstring::value_type  sep 
)
inline

Join a list of items into a string.

Definition at line 260 of file stringhelper.h.

References join_worker().

◆ join_worker()

template<typename Iterator , typename Separator >
void log4cplus::helpers::join_worker ( tstring result,
Iterator &  start,
Iterator &  last,
Separator const &  sep 
)
inline

Join a list of items into a string.

Definition at line 233 of file stringhelper.h.

Referenced by join().

◆ localTime()

LOG4CPLUS_EXPORT void log4cplus::helpers::localTime ( tm *  t,
Time const &   
)

Populates tm using the localtime() function.

◆ microseconds_part()

long log4cplus::helpers::microseconds_part ( Time const &  the_time)
inline

Definition at line 111 of file timehelper.h.

References from_time_t(), and to_time_t().

◆ now()

Time log4cplus::helpers::now ( )
inline

Definition at line 68 of file timehelper.h.

References time_cast().

◆ openSocket() [1/2]

LOG4CPLUS_EXPORT SOCKET_TYPE log4cplus::helpers::openSocket ( tstring const &  host,
unsigned short  port,
bool  udp,
bool  ipv6,
SocketState state 
)

◆ openSocket() [2/2]

LOG4CPLUS_EXPORT SOCKET_TYPE log4cplus::helpers::openSocket ( unsigned short  port,
bool  udp,
bool  ipv6,
SocketState state 
)

◆ read()

LOG4CPLUS_EXPORT long log4cplus::helpers::read ( SOCKET_TYPE  sock,
SocketBuffer buffer 
)

◆ readFromBuffer()

LOG4CPLUS_EXPORT log4cplus::spi::InternalLoggingEvent log4cplus::helpers::readFromBuffer ( SocketBuffer buffer)

◆ set_last_socket_error()

static void log4cplus::helpers::set_last_socket_error ( int  err)
inlinestatic

Definition at line 200 of file internal/socket.h.

◆ setTCPNoDelay()

LOG4CPLUS_EXPORT int log4cplus::helpers::setTCPNoDelay ( SOCKET_TYPE  ,
bool   
)

◆ shutdownSocket()

LOG4CPLUS_EXPORT int log4cplus::helpers::shutdownSocket ( SOCKET_TYPE  sock)

◆ time_cast()

template<typename FromDuration >
Time log4cplus::helpers::time_cast ( chrono::time_point< Clock, FromDuration > const &  tp)
inline

Definition at line 60 of file timehelper.h.

Referenced by from_time_t(), and now().

◆ time_from_parts()

Time log4cplus::helpers::time_from_parts ( time_t  tv_sec,
long  tv_usec 
)
inline

Definition at line 124 of file timehelper.h.

References from_time_t().

◆ to_log4cplus_socket()

static SOCKET_TYPE log4cplus::helpers::to_log4cplus_socket ( os_socket_type const &  x)
inlinestatic

Definition at line 192 of file internal/socket.h.

◆ to_os_socket()

static os_socket_type log4cplus::helpers::to_os_socket ( SOCKET_TYPE const &  x)
inlinestatic

Definition at line 184 of file internal/socket.h.

◆ to_time_t()

time_t log4cplus::helpers::to_time_t ( Time const &  the_time)
inline

Definition at line 84 of file timehelper.h.

References from_time_t().

Referenced by microseconds_part(), and truncate_fractions().

◆ tokenize()

template<class StringType , class OutputIter >
void log4cplus::helpers::tokenize ( const StringType &  s,
typename StringType::value_type  c,
OutputIter  result,
bool  collapseTokens = true 
)
inline

Tokenize s using c as the delimiter and put the resulting tokens in _result.

If collapseTokens is false, multiple adjacent delimiters will result in zero length tokens.

Example:

  string s = // Set string with '.' as delimiters
  list<log4cplus::tstring> tokens;
  tokenize(s, '.', back_insert_iterator<list<string> >(tokens));

Definition at line 72 of file stringhelper.h.

◆ toLower() [1/2]

LOG4CPLUS_EXPORT log4cplus::tstring log4cplus::helpers::toLower ( const log4cplus::tstring s)

Returns s in lower case.

◆ toLower() [2/2]

LOG4CPLUS_EXPORT tchar log4cplus::helpers::toLower ( tchar  )

◆ tostring() [1/6]

std::string log4cplus::helpers::tostring ( char const *  str)
inline

Definition at line 47 of file tstring.h.

◆ tostring() [2/6]

LOG4CPLUS_EXPORT std::string log4cplus::helpers::tostring ( const std::wstring &  )

◆ tostring() [3/6]

std::string log4cplus::helpers::tostring ( std::string &&  str)
inline

Definition at line 68 of file tstring.h.

◆ tostring() [4/6]

std::string const& log4cplus::helpers::tostring ( std::string &  str)
inline

Definition at line 61 of file tstring.h.

◆ tostring() [5/6]

std::string log4cplus::helpers::tostring ( std::string const &  str)
inline

Definition at line 54 of file tstring.h.

◆ tostring() [6/6]

LOG4CPLUS_EXPORT std::string log4cplus::helpers::tostring ( wchar_t const *  )

◆ toUpper() [1/2]

LOG4CPLUS_EXPORT log4cplus::tstring log4cplus::helpers::toUpper ( const log4cplus::tstring s)

Returns s in upper case.

◆ toUpper() [2/2]

LOG4CPLUS_EXPORT tchar log4cplus::helpers::toUpper ( tchar  )

◆ towstring() [1/6]

LOG4CPLUS_EXPORT std::wstring log4cplus::helpers::towstring ( char const *  )

◆ towstring() [2/6]

LOG4CPLUS_EXPORT std::wstring log4cplus::helpers::towstring ( const std::string &  )

◆ towstring() [3/6]

std::wstring log4cplus::helpers::towstring ( std::wstring &&  str)
inline

Definition at line 97 of file tstring.h.

◆ towstring() [4/6]

std::wstring const& log4cplus::helpers::towstring ( std::wstring &  str)
inline

Definition at line 90 of file tstring.h.

◆ towstring() [5/6]

std::wstring log4cplus::helpers::towstring ( std::wstring const &  str)
inline

Definition at line 83 of file tstring.h.

◆ towstring() [6/6]

std::wstring log4cplus::helpers::towstring ( wchar_t const *  str)
inline

Definition at line 76 of file tstring.h.

◆ truncate_fractions()

Time log4cplus::helpers::truncate_fractions ( Time const &  the_time)
inline

Definition at line 103 of file timehelper.h.

References from_time_t(), and to_time_t().

◆ write() [1/3]

LOG4CPLUS_EXPORT long log4cplus::helpers::write ( SOCKET_TYPE  sock,
const SocketBuffer buffer 
)

◆ write() [2/3]

LOG4CPLUS_EXPORT long log4cplus::helpers::write ( SOCKET_TYPE  sock,
const std::string &  buffer 
)

◆ write() [3/3]

LOG4CPLUS_EXPORT long log4cplus::helpers::write ( SOCKET_TYPE  sock,
std::size_t  bufferCount,
SocketBuffer const *const *  buffers 
)

Variable Documentation

◆ ConnectorThread

Definition at line 1 of file connectorthread.h.

◆ INVALID_OS_SOCKET_VALUE

os_socket_type const log4cplus::helpers::INVALID_OS_SOCKET_VALUE = INVALID_SOCKET

◆ INVALID_SOCKET_VALUE

LOG4CPLUS_EXPORT SOCKET_TYPE const log4cplus::helpers::INVALID_SOCKET_VALUE
extern