| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // logger.hpp
- // logger
- //
- // Created by Sam Jaffe on 9/3/16.
- //
- #pragma once
- //
- // Logger.hpp
- // DanmakuRPG
- //
- // Created by Sam Jaffe on 7/18/15.
- // Copyright (c) 2015 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <cstdarg>
- #include <cstdlib>
- #include <cstring>
- #include <memory>
- #include <string>
- #include "message.h"
- #define log_message( logger, lvl, ... ) \
- logger.log(level::lvl, log_here, __VA_ARGS__)
- namespace logging {
- enum class level : int;
- struct location_info;
- class logger_impl;
- struct logpacket;
- class logger {
- public:
- ~logger();
- template <typename... Args>
- inline void log(level ll, std::string const & interp, Args && ...args) {
- log(ll, message(interp, std::forward<Args>(args)...));
- }
-
- template <typename... Args>
- inline void log(level ll, location_info const & info,
- std::string const & interp, Args && ...args) {
- log(ll, info, message(interp, std::forward<Args>(args)...));
- }
-
- void log(level ll, message const&);
- void flush();
-
- protected:
- logger(std::string const & name, std::shared_ptr<logger_impl> impl);
-
- private:
- friend class manager;
- void log(level ll, location_info const & info, message const&);
- private:
- std::string const logger_name_;
- std::shared_ptr<logger_impl> impl_;
- };
- }
|