Skip to content

Commit

Permalink
ews: replace open-coded time unit conversion in request logging
Browse files Browse the repository at this point in the history
Defer calling .count() until it is actually needed at the printf site
to increase type safety involving the age() function.
  • Loading branch information
jengelh committed Sep 25, 2024
1 parent ee52a7e commit 9bb3a8e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions exch/ews/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ EWSContext::~EWSContext()
unsubscribe(sub);
}

double EWSContext::age() const
{
return std::chrono::duration<double>(tp_now() - m_created).count();
}

/**
* @brief Copy string to context allocated buffer
*
Expand Down
2 changes: 1 addition & 1 deletion exch/ews/ews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ int EWSPlugin::retr(int ctx_id) try
mlog(loglevel, "[ews#%d]%s Done, code %d, %zu bytes, %.3fms",
ctx_id, timestamp().c_str(),
static_cast<int>(context.code()),
sv.size(), context.age() * 1000);
sv.size(), std::chrono::duration<double, std::milli>(context.age()).count());
return HPM_RETRIEVE_WRITE;
}
case EWSContext::S_DONE: return HPM_RETRIEVE_DONE;
Expand Down
2 changes: 1 addition & 1 deletion exch/ews/ews.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class EWSContext {
void validate(const std::string&, const Structures::sMessageEntryId&) const;
void writePermissions(const std::string&, uint64_t, const std::vector<PERMISSION_DATA>&) const;

double age() const;
gromox::time_duration age() const { return tp_now() - m_created; }
void experimental(const char*) const;

inline int ID() const {return m_ID;}
Expand Down

0 comments on commit 9bb3a8e

Please sign in to comment.