A C++ library for logging very fast and without allocating.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 line
360 B

  1. #include <span>
  2. #include "sl/logger.h"
  3. #include "registry.h"
  4. namespace sl {
  5. void log(int log_id, std::string line) {
  6. auto& slab = registry_map.at(log_id);
  7. auto token = slab.reserve_write(line.size());
  8. auto span = slab.get_buffer(token);
  9. for(auto elem : line) {
  10. span.front() = elem;
  11. span = span.subspan(1);
  12. }
  13. slab.conclude_write(token);
  14. }
  15. }