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