Skip to content

Commit abd818b

Browse files
Create time.hpp
1 parent ef89da7 commit abd818b

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

include/tactile/core/log/logger.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#pragma once
55

6-
#include <chrono>
76
#include <format>
87

98
#include "tactile/core/container/smart_ptr.hpp"
@@ -12,14 +11,15 @@
1211
#include "tactile/core/log/log_category.hpp"
1312
#include "tactile/core/log/log_sink.hpp"
1413
#include "tactile/core/util/format_buffer.hpp"
14+
#include "tactile/core/util/time.hpp"
1515

1616
namespace tactile {
1717

1818
/// A sink based logger implementation.
1919
class Logger final
2020
{
2121
public:
22-
using clock_type = std::chrono::steady_clock;
22+
using clock_type = SteadyClock;
2323

2424
/// Adds a sink to logger.
2525
void add_sink(Unique<ILogSink> sink);

include/tactile/core/util/time.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (C) 2025 Albin Johansson
2+
// This software is provided under the terms of the MIT License.
3+
4+
#pragma once
5+
6+
#include <chrono>
7+
8+
namespace tactile {
9+
10+
using SystemClock = std::chrono::system_clock;
11+
using SteadyClock = std::chrono::steady_clock;
12+
13+
using Milliseconds = std::chrono::milliseconds;
14+
using Microseconds = std::chrono::microseconds;
15+
16+
using std::chrono::duration_cast;
17+
18+
} // namespace tactile

src/tactile/core/log/logger.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ void Logger::log_impl(const LogCategory category,
6868
}
6969

7070
const auto now = clock_type::now();
71-
const auto elapsed_time =
72-
std::chrono::duration_cast<std::chrono::microseconds>(now - m_ref_instant);
71+
const auto elapsed_time = duration_cast<Microseconds>(now - m_ref_instant);
7372

7473
const auto category_label = to_prefix_label(category);
7574

tools/cmake/targets/tactile_core.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ target_sources(tactile_core
3232
"${PROJECT_SOURCE_DIR}/include/tactile/core/meta/opacity.hpp"
3333
"${PROJECT_SOURCE_DIR}/include/tactile/core/tile/tile_id.hpp"
3434
"${PROJECT_SOURCE_DIR}/include/tactile/core/util/defer.hpp"
35+
"${PROJECT_SOURCE_DIR}/include/tactile/core/util/time.hpp"
3536
"${PROJECT_SOURCE_DIR}/include/tactile/core/util/format_buffer.hpp"
3637
"${PROJECT_SOURCE_DIR}/include/tactile/core/casts.hpp"
3738
"${PROJECT_SOURCE_DIR}/include/tactile/core/concepts.hpp"

0 commit comments

Comments
 (0)