Skip to content

Commit 04f76dd

Browse files
committed
clang-format
1 parent fd1f7ae commit 04f76dd

File tree

6 files changed

+70
-71
lines changed

6 files changed

+70
-71
lines changed

include/InfoLogger/InfoLogger.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ class InfoLogger
138138
/// Constructor
139139
/// May throw exceptions on failure.
140140
InfoLogger();
141-
141+
142142
// Constructor
143143
// with optional options
144-
// provided as a comma-separated list of key=value pairs
145-
InfoLogger(const std::string &options);
144+
// provided as a comma-separated list of key=value pairs
145+
InfoLogger(const std::string& options);
146146

147147
/// Destructor
148148
virtual ~InfoLogger();

src/InfoLogger.cxx

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -176,101 +176,101 @@ namespace InfoLogger
176176
class InfoLogger::Impl
177177
{
178178
public:
179-
Impl(const std::string &options)
179+
Impl(const std::string& options)
180180
{
181181
// initiate internal members
182182
magicTag = InfoLoggerMagicNumber;
183183
numberOfMessages = 0;
184184
currentStreamMessage.clear();
185185
currentStreamOptions = undefinedMessageOption;
186186
client = nullptr;
187-
187+
188188
floodReset();
189189

190190
if (infoLog_proto_init()) {
191191
throw __LINE__;
192192
}
193193
refreshDefaultMsg();
194194

195-
// option-processing routine
196-
auto processOptions = [&] (std::string opt) {
195+
// option-processing routine
196+
auto processOptions = [&](std::string opt) {
197197
std::map<std::string, std::string> kv;
198198
if (getKeyValuePairsFromString(opt, kv)) {
199-
throw __LINE__;
199+
throw __LINE__;
200200
}
201201
for (auto& it : kv) {
202-
if (it.first == "outputMode") {
202+
if (it.first == "outputMode") {
203203
getOutputStreamFromString(it.second.c_str(), mainMode);
204-
} else if (it.first == "outputModeFallback") {
204+
} else if (it.first == "outputModeFallback") {
205205
getOutputStreamFromString(it.second.c_str(), fallbackMode);
206-
} else if (it.first == "verbose") {
206+
} else if (it.first == "verbose") {
207207
verbose = atoi(it.second.c_str());
208-
} else {
209-
// unknown option
208+
} else {
209+
// unknown option
210210
// printf("Unknown option %s\n",it.second.c_str());
211211
throw __LINE__;
212-
}
212+
}
213213
}
214214
return;
215215
};
216-
216+
217217
// parse options from constructor arg
218218
processOptions(options);
219219

220-
// parse options from environment
220+
// parse options from environment
221221
const char* confEnvOptions = getenv("INFOLOGGER_OPTIONS");
222222
if (confEnvOptions != NULL) {
223-
processOptions(confEnvOptions);
223+
processOptions(confEnvOptions);
224224
}
225225

226226
const char* confEnvMode = getenv("INFOLOGGER_MODE");
227227
if (confEnvMode != NULL) {
228228
getOutputStreamFromString(confEnvMode, mainMode);
229229
}
230-
231-
// init main output and fallbacks if needed
230+
231+
// init main output and fallbacks if needed
232232
currentMode = mainMode;
233-
for (int it = 0; it < 3 ; it++) {
233+
for (int it = 0; it < 3; it++) {
234234
if (it == 0) {
235235
currentMode = mainMode;
236236
} else if (it == 1) {
237237
currentMode = fallbackMode;
238238
} else {
239239
currentMode.mode = OutputMode::none;
240-
currentMode.path = "/dev/null";
240+
currentMode.path = "/dev/null";
241241
}
242242
if (verbose) {
243243
printf("Using output mode %s\n", getStringFromMode(currentMode.mode));
244244
}
245-
245+
246246
if (currentMode.mode == OutputMode::file) {
247-
if (verbose) {
248-
printf("Logging to file %s\n", currentMode.path.c_str());
249-
}
250-
if (stdLog.setLogFile(currentMode.path.c_str(),0,4,0) == 0) {
247+
if (verbose) {
248+
printf("Logging to file %s\n", currentMode.path.c_str());
249+
}
250+
if (stdLog.setLogFile(currentMode.path.c_str(), 0, 4, 0) == 0) {
251251
break;
252-
}
252+
}
253253
} else if (currentMode.mode == OutputMode::stdout) {
254-
if (stdLog.setLogFile(nullptr) == 0) {
255-
break;
256-
}
254+
if (stdLog.setLogFile(nullptr) == 0) {
255+
break;
256+
}
257257
} else if (currentMode.mode == OutputMode::none) {
258-
if (stdLog.setLogFile(currentMode.path.c_str()) == 0) {
258+
if (stdLog.setLogFile(currentMode.path.c_str()) == 0) {
259259
break;
260-
}
260+
}
261261
} else if (currentMode.mode == OutputMode::infoLoggerD) {
262-
client = new InfoLoggerClient;
263-
if (client != nullptr) {
262+
client = new InfoLoggerClient;
263+
if (client != nullptr) {
264264
if (client->isOk()) {
265-
break;
266-
}
267-
}
265+
break;
266+
}
267+
}
268268
}
269269
if (verbose) {
270-
printf("Output to %s failed\n", getStringFromMode(currentMode.mode));
270+
printf("Output to %s failed\n", getStringFromMode(currentMode.mode));
271271
}
272272
}
273-
273+
274274
// todo
275275
// switch mode based on configuration / environment
276276
// connect to client only on first message (or try again after timeout)
@@ -305,59 +305,61 @@ class InfoLogger::Impl
305305
none };
306306

307307
struct OutputStream {
308-
OutputMode mode; // selected mode
308+
OutputMode mode; // selected mode
309309
std::string path; // optional path (eg for 'file' mode)
310310
};
311-
311+
312312
// convert a string to a member of the OutputMode enum
313313
// and sets filePath in case of the "file" mode
314314
// throw an integer error code on error
315-
void getOutputStreamFromString(const char *s, OutputStream &out) {
315+
void getOutputStreamFromString(const char* s, OutputStream& out)
316+
{
316317
if (s == nullptr) {
317318
throw __LINE__;
318319
}
319320
out.mode = OutputMode::none;
320321
out.path = "";
321-
if (!strcmp(s,"stdout")) {
322+
if (!strcmp(s, "stdout")) {
322323
out.mode = OutputMode::stdout;
323-
} else if (!strncmp(s,"file", 4)) {
324+
} else if (!strncmp(s, "file", 4)) {
324325
out.mode = OutputMode::file;
325326
if (s[4] == ':') {
326327
out.path = std::string(&s[5]);
327328
} else {
328329
out.path = "./log.txt";
329330
}
330-
} else if (!strcmp(s,"infoLoggerD")) {
331+
} else if (!strcmp(s, "infoLoggerD")) {
331332
out.mode = OutputMode::infoLoggerD;
332-
} else if (!strcmp(s,"raw")) {
333+
} else if (!strcmp(s, "raw")) {
333334
out.mode = OutputMode::raw;
334-
} else if (!strcmp(s,"none")) {
335+
} else if (!strcmp(s, "none")) {
335336
out.mode = OutputMode::none;
336337
} else {
337338
throw __LINE__;
338339
}
339340
return;
340341
};
341-
342-
const char* getStringFromMode(OutputMode m) {
343-
if (m==OutputMode::stdout) {
342+
343+
const char* getStringFromMode(OutputMode m)
344+
{
345+
if (m == OutputMode::stdout) {
344346
return "stdout";
345-
} else if (m==OutputMode::file) {
347+
} else if (m == OutputMode::file) {
346348
return "file";
347-
} else if (m==OutputMode::infoLoggerD) {
349+
} else if (m == OutputMode::infoLoggerD) {
348350
return "infoLoggerD";
349-
} else if (m==OutputMode::none) {
351+
} else if (m == OutputMode::none) {
350352
return "none";
351-
}
353+
}
352354
return "unknown";
353355
}
354-
355-
OutputStream currentMode; // current option for output
356-
OutputStream mainMode = {OutputMode::infoLoggerD, ""}; // main output mode
357-
OutputStream fallbackMode = {OutputMode::stdout, ""}; // in case main mode is not available
358-
356+
357+
OutputStream currentMode; // current option for output
358+
OutputStream mainMode = { OutputMode::infoLoggerD, "" }; // main output mode
359+
OutputStream fallbackMode = { OutputMode::stdout, "" }; // in case main mode is not available
360+
359361
bool verbose = 0; // in verbose mode, more info printed on stdout
360-
362+
361363
/// Log a message, with a list of arguments of type va_list.
362364
/// \param message NUL-terminated string message to push to the log system. It uses the same format as specified for printf(), and the function accepts additionnal formatting parameters.
363365
/// \param ap Variable list of arguments (c.f. vprintf)
@@ -729,7 +731,7 @@ InfoLogger::InfoLogger()
729731
}
730732
}
731733

732-
InfoLogger::InfoLogger(const std::string &options)
734+
InfoLogger::InfoLogger(const std::string& options)
733735
{
734736
mPimpl = std::make_unique<InfoLogger::Impl>(options);
735737
if (mPimpl == NULL) {

src/InfoLoggerScripting.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ InfoLogger::InfoLogger()
2222
{
2323
logHandle = std::make_unique<baseInfoClass>();
2424
}
25-
InfoLogger::InfoLogger(const std::string &options)
25+
InfoLogger::InfoLogger(const std::string& options)
2626
{
2727
logHandle = std::make_unique<baseInfoClass>(options);
2828
}

src/InfoLoggerScripting.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class InfoLogger
7676
{
7777
public:
7878
InfoLogger();
79-
InfoLogger(const std::string &options);
79+
InfoLogger(const std::string& options);
8080
~InfoLogger();
8181

8282
// log with default metadata fields and specified severity

src/infoLoggerUtils.cxx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#include "infoLoggerUtils.h"
1212

13-
14-
1513
int getKeyValuePairsFromString(const std::string& input, std::map<std::string, std::string>& output)
1614
{
1715
output.clear();
@@ -24,16 +22,16 @@ int getKeyValuePairsFromString(const std::string& input, std::map<std::string, s
2422
if (ix2 >= ix1) {
2523
break;
2624
} // end of string
27-
25+
2826
const std::string& trimchars = "\t\n\v\f\r ";
29-
27+
3028
// trim key
3129
std::string key = input.substr(ix0, ix2 - ix0);
3230
key.erase(key.find_last_not_of(trimchars) + 1);
3331
key.erase(0, key.find_first_not_of(trimchars));
34-
32+
3533
// trim value
36-
std::string value;
34+
std::string value;
3735
if (ix1 == std::string::npos) {
3836
value = input.substr(ix2 + 1);
3937
} else {
@@ -44,7 +42,7 @@ int getKeyValuePairsFromString(const std::string& input, std::map<std::string, s
4442

4543
// insert in map
4644
output.insert(std::pair<std::string, std::string>(key, value));
47-
45+
4846
// iterate next pair unless end of string
4947
if (ix1 == std::string::npos) {
5048
break;

test/testInfoLoggerDB.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <sys/types.h>
66
#include <unistd.h>
77

8-
98
#if LIBMYSQL_VERSION_ID >= 80000
109
typedef bool my_bool;
1110
#endif

0 commit comments

Comments
 (0)