|
static Residue & | instance () noexcept |
| Singleton instance.
|
|
static std::string | version () noexcept |
| Version of Residue library.
|
|
static std::string | info () noexcept |
| Version of Residue library and dependencies.
|
|
static void | connect (const std::string &host, int port) |
| Connect to residue on specified host and port. More...
|
|
static void | connect (int port) |
| Connect to residue on localhost. More...
|
|
static void | connect (const std::string &host) |
| Connect to residue using default port. More...
|
|
static void | connect () |
| Connect to residue on localhost using default port. This is more useful when you have client ID so you won't have varying client IDs. More...
|
|
static void | reconnect (const std::string &host="", int port=-1) |
| Reconnects residue server using new or initially provided parameters. (Disconnect then connect) More...
|
|
static bool | connected () noexcept |
| Check connection to the server. More...
|
|
static const std::string & | clientId () noexcept |
| Returns current client ID. Returns empty if not connected.
|
|
static bool | connecting () noexcept |
| Check connection to the server. More...
|
|
static unsigned int | maxBulkSize () noexcept |
| If connected this identifies maximum number of items in bulk that server accepts.
|
|
static unsigned int | serverFlags () noexcept |
| If connected this identifies server flags.
|
|
static void | disconnect () noexcept |
| Safely disconnects from the server. This will also call wait() More...
|
|
static void | wait () noexcept |
| Wait to dispatch all the log requests to the server.
|
|
static void | setApplicationId (const std::string &id) noexcept |
| Application ID is what gets passed on to the server for app format specifier.
|
|
static void | setResidueHomePath (const std::string &path) noexcept |
| Sets residue home path for $RESIDUE_HOME.
|
|
static void | enableBulkDispatch () |
| enableBulkDispatch turns on bulk dispatch. More...
|
|
static void | disableBulkDispatch () noexcept |
| disableBulkDispatch turns off bulk dispatch.
|
|
static void | enableUtc () noexcept |
| Send UTC time to the server. By default local time is sent.
|
|
static void | disableUtc () noexcept |
| Send Local time to the server. By default local time is sent.
|
|
static void | setTimeOffset (int offset) noexcept |
| Offset in seconds for log time. [Default: 0].
|
|
static void | setDispatchDelay (unsigned int delay) noexcept |
| Delay between dispatching log messages (in milliseconds) [Default: 1ms]. More...
|
|
static void | setBulkSize (unsigned int bulkSize) |
| Sets number of log messages to be bulked together. More...
|
|
static void | enableAutoBulkParams () noexcept |
| Enables automatic setting of bulk parameters depending on what's most efficient. It essentially enables bulk if server supports it and sets bulk size and dispatch delay accordingly. More...
|
|
static void | disableAutoBulkParams () noexcept |
| Disables automatic setting of bulk params. More...
|
|
static void | setKeySize (std::size_t keySize) |
| Size of RSA key (in bits) when connecting. More...
|
|
static void | setApplicationArgs (int argc, char **argv) |
|
static void | setApplicationArgs (int argc, const char **argv) |
| Wrapper for START_EASYLOGGINGPP. More...
|
|
static void | setKnownClient (const std::string &clientId, const std::string &privateKeyPem) |
| If server knows you already you can let us know and we will use this identity. More...
|
|
static void | setServerPublicKey (const std::string &publicKeyPem) |
| Sets server public key for encrypted connection. More...
|
|
static void | setInternalLoggingLevel (int level) |
| Sets logging level for residue client library internal logging. More...
|
|
static void | setInternalLoggingLevel (InternalLoggingLevel level) |
| Helper function to set logging level for debugging/info. More...
|
|
static bool | hasFlag (Flag flag) noexcept |
| Checks for server flag and returns true if flag set otherwise not.
|
|
static void | setThreadName (const std::string &threadName) noexcept |
| Sets current thread name.
|
|
static void | enableCrashHandler (const std::string &loggerId=el::base::consts::kDefaultLoggerId) |
| Enables crash handler. More...
|
|
static const std::vector< std::string > & | errors () noexcept |
| Useful for debugging the issue. Contains last 10 errors from server (i.e, error_text in response) Last error is the latest, second last is second latest, ...
|
|
static void | loadConfigurationFromJson (const std::string &json) |
| Loads configuration from JSON. More...
|
|
static void | saveConnection (const std::string &outputFile) |
| Saves connection parameter to the file. More...
|
|
static std::string | connection () |
|
static void | loadConnectionFromJson (const std::string &connectionJson) |
| Loads configuration from JSON. More...
|
|
The Residue class provides helper methods to connect and interact to residue server seamlessly.
static void Residue::setDispatchDelay |
( |
unsigned int |
delay | ) |
|
|
inlinestaticnoexcept |
Delay between dispatching log messages (in milliseconds) [Default: 1ms].
Setting correct delay is very important depending on your application and needs. Some applications that run for long (e.g, GUI application) may need longer delays between collecting log message and dispatching them to the server. This is very helpful for bulk requests in combination with compression enabled servers. When you collect many messages before they are dispatched to the server and you have bulk request and compression enabled, there are more changes of similar strings, meaning smaller packets.
For example, if you have dispatch delay set to 10000 (10 seconds) and you have bulk requests (size 20) and compression enabled, when you log messages (using any method, e.g, LOG(INFO)...) it is going to hold the message in local memory for 10 seconds. Let's say within 10 seconds you logged 100 times, in this situation there are high chances you will have duplicate strings (for example lots of ":" or alphabets (e.g, "a") hence the compression will be much more useful.
static void loadConfiguration |
( |
const std::string & |
jsonFilename | ) |
|
|
related |
Loads all the configurations from JSON file.
A JSON file should look similar to. Only
url
is required, rest of them are optional
{
"url": "localhost:8777",
"application_id": "com.muflihun.sampleapp",
"rsa_key_size": 2048,
"utc_time": false,
"time_offset": -3600,
"dispatch_delay": 1,
"main_thread_id": "main_thread",
"client_id": "my_client",
"client_private_key": "client-private.pem",
"client_key_secret": "",
"server_public_key": "server-public.pem",
"internal_logging_level": 2
}
- Parameters
-
jsonFilename | Path to configuration JSON file (const std::string&) |