salsa  0.3.0
 All Classes Functions Variables Enumerations Pages
Log.hh
1 #pragma once
2 #include <memory>
3 #include <spdlog/sinks/basic_file_sink.h>
4 #include <spdlog/sinks/stdout_sinks.h>
5 #include <string>
6 #include <vector>
7 namespace Salsa {
16 
17 class Log {
18 public:
19  Log();
20  ~Log();
21 
23  int add(std::string);
25  void name(char const * pNewName) { mName = pNewName; }
27  void name(std::string newName) { mName = newName; }
28 
30  std::string name() const { return mName; }
31 
33  int create();
35  int write(char const *);
37  std::shared_ptr<spdlog::logger> spd() { return mpTarget; }
39  int empty() { return mSinks.empty(); }
40 
42  void fd(int newFD) { mFD = newFD; }
44  int fd() const { return mFD; }
45 
46 private:
47  int mFD = -1;
48  static uint64_t msID;
49  std::string mName = nullptr;
50  std::vector<spdlog::sink_ptr> mSinks;
51  std::shared_ptr<spdlog::logger> mpTarget = nullptr;
52 };
53 } // namespace Salsa
std::shared_ptr< spdlog::logger > spd()
Get SPDLOG logger handle.
Definition: Log.hh:37
int mFD
FD of current pipe.
Definition: Log.hh:47
static uint64_t msID
Static Job newName (holds index)
Definition: Log.hh:48
void fd(int newFD)
Set FD of pipe to watch.
Definition: Log.hh:42
int write(char const *)
Write to logger.
Definition: Log.cc:49
std::string mName
newName (name) of current job
Definition: Log.hh:49
int fd() const
Get FD of currently watched pipe.
Definition: Log.hh:44
void name(char const *pNewName)
Set name of job (only used for spdlog logger identification)
Definition: Log.hh:25
std::vector< spdlog::sink_ptr > mSinks
Sinks for SPDLOG.
Definition: Log.hh:50
Definition: Log.hh:17
void name(std::string newName)
Set name of job (only used for spdlog logger identification)
Definition: Log.hh:27
int create()
Create SPDLOG loger.
Definition: Log.cc:31
std::shared_ptr< spdlog::logger > mpTarget
SPDLOG logger handle.
Definition: Log.hh:51
int empty()
Get info about sinks.
Definition: Log.hh:39
std::string name() const
Get name of job (only used for spdlog logger identification)
Definition: Log.hh:30
int add(std::string)
Add output sink (file, console, zmq) for SPDLOG.
Definition: Log.cc:10