﷽
Residue comes with official C++ client library for users to use in their C++ applications. You can easily integrate residue in to your existing C++ application with literally 3 changes.
For other client libraries please refer to corresponding repository.
You need 2 things to connect to residue
residue.h
header file - this contains API for connecting to the residue serverlibresidue
(a dynamic library) - you will need to link your application to this library in order to successfully compile.
We highly recommend usage of libresidue-static
static library as dynamic linking will need applications to further link to other dynamic libraries.
Make sure you define ELPP_THREAD_SAFE
preprocessor at compile level (whole application takes this affect)
In your main()
, send connection to residue. (NOTE: Residue server should be running in order to connect otherwise you will get error)
#include <residue/residue.h>
int main() {
// Connects to localhost on Residue::DEFAULT_PORT (8777)
/
/ You can catch ResidueException for connection failure
Residue::connect();
///
/// Start logging using Easylogging++ macros i.e, LOG(INFO) etc
///
/// If you wish to log using specific logger you will have to use CLOG(INFO, "<logger-id>")
/// See https://github.com/abumq/easyloggingpp#logging for details
///
// It's always best to safely disconnect before your application ends, this ensures
// all the logs have been flushed to the server
Residue::disconnect();
return 0;
}
Please refer to this link for documentation for API