Public Member Functions | Public Attributes | Private Attributes | List of all members
spdlog::details::z_formatter Class Referencefinal

#include <pattern_formatter.h>

Inheritance diagram for spdlog::details::z_formatter:
spdlog::details::flag_formatter

Public Member Functions

 z_formatter (padding_info padinfo)
 
 z_formatter ()=default
 
 z_formatter (const z_formatter &)=delete
 
z_formatteroperator= (const z_formatter &)=delete
 
void format (const details::log_msg &msg, const std::tm &tm_time, fmt::memory_buffer &dest) override
 
- Public Member Functions inherited from spdlog::details::flag_formatter
 flag_formatter (padding_info padinfo)
 
 flag_formatter ()=default
 
virtual ~flag_formatter ()=default
 

Public Attributes

const std::chrono::seconds cache_refresh = std::chrono::seconds(5)
 

Private Attributes

log_clock::time_point last_update_ {std::chrono::seconds(0)}
 

Additional Inherited Members

- Protected Attributes inherited from spdlog::details::flag_formatter
padding_info padinfo_
 

Detailed Description

Definition at line 623 of file pattern_formatter.h.

Constructor & Destructor Documentation

spdlog::details::z_formatter::z_formatter ( padding_info  padinfo)
inlineexplicit

Definition at line 626 of file pattern_formatter.h.

627  : flag_formatter(padinfo){};
spdlog::details::z_formatter::z_formatter ( )
default
spdlog::details::z_formatter::z_formatter ( const z_formatter )
delete

Member Function Documentation

void spdlog::details::z_formatter::format ( const details::log_msg msg,
const std::tm &  tm_time,
fmt::memory_buffer dest 
)
inlineoverridevirtual

Implements spdlog::details::flag_formatter.

Definition at line 635 of file pattern_formatter.h.

636  {
637  const size_t field_size = 6;
638  scoped_pad p(field_size, padinfo_, dest);
639 
640 #ifdef _WIN32
641  int total_minutes = get_cached_offset(msg, tm_time);
642 #else
643  // No need to chache under gcc,
644  // it is very fast (already stored in tm.tm_gmtoff)
645  (void)(msg);
646  int total_minutes = os::utc_minutes_offset(tm_time);
647 #endif
648  bool is_negative = total_minutes < 0;
649  if (is_negative)
650  {
651  total_minutes = -total_minutes;
652  dest.push_back('-');
653  }
654  else
655  {
656  dest.push_back('+');
657  }
658 
659  fmt_helper::pad2(total_minutes / 60, dest); // hours
660  dest.push_back(':');
661  fmt_helper::pad2(total_minutes % 60, dest); // minutes
662  }
void msg(const char *fmt,...)
Definition: message.cpp:107
int utc_minutes_offset(const std::tm &tm=details::os::localtime())
Definition: os.h:249
p
Definition: test.py:223
FMT_CONSTEXPR std::enable_if< std::numeric_limits< T >::is_signed, bool >::type is_negative(T value)
Definition: format.h:727
void pad2(int n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
Definition: fmt_helper.h:54
z_formatter& spdlog::details::z_formatter::operator= ( const z_formatter )
delete

Member Data Documentation

const std::chrono::seconds spdlog::details::z_formatter::cache_refresh = std::chrono::seconds(5)

Definition at line 629 of file pattern_formatter.h.

log_clock::time_point spdlog::details::z_formatter::last_update_ {std::chrono::seconds(0)}
private

Definition at line 665 of file pattern_formatter.h.


The documentation for this class was generated from the following file: