Permalink
Browse files

Added option to log to stdout

  • Loading branch information...
1 parent f590c6b commit a0cbee70c368182a7c820037af7185785366409a Caleb James DeLisle committed Mar 1, 2013
Showing with 20 additions and 6 deletions.
  1. +9 −4 admin/angel/Core.c
  2. +11 −2 admin/angel/cjdroute2.c
View
@@ -300,10 +300,15 @@ int Core_main(int argc, char** argv)
Hermes_callAngel(&response, angelResponse, NULL, alloc, eh, hermes);
// --------------------- Setup the Logger --------------------- //
- // the prelogger will nolonger be used.
- struct Log* adminLogger = AdminLog_registerNew(admin, alloc, rand);
- indirectLogger->wrappedLog = adminLogger;
- logger = adminLogger;
+ Dict* logging = Dict_getDict(config, String_CONST("logging"));
+ String* logTo = Dict_getString(logging, String_CONST("logTo"));
+ if (logTo && String_equals(logTo, String_CONST("stdout"))) {
+ // do nothing, continue logging to stdout.
+ } else {
+ struct Log* adminLogger = AdminLog_registerNew(admin, alloc, rand);
+ indirectLogger->wrappedLog = adminLogger;
+ logger = adminLogger;
+ }
// CryptoAuth
struct Address addr;
View
@@ -334,8 +334,13 @@ static int genconf(struct Random* rand)
" }\n"
" ],\n"
"\n"
- " // Version of the config file, used internally for migration.\n"
- " \"version\": 1\n"
+ " // Logging\n"
+ " \"logging\":\n"
+ " {\n"
+ " // Uncomment to have cjdns log to stdout rather than making logs available\n"
+ " // via the admin socket.\n"
+ " // \"logTo\":\"stdout\"\n"
+ " }\n"
"}\n");
return 0;
@@ -502,6 +507,10 @@ int main(int argc, char** argv)
if (securityUser) {
Dict_putString(adminPreConf, String_CONST("user"), securityUser, allocator);
}
+ Dict* logging = Dict_getDict(&config, String_CONST("logging"));
+ if (logging) {
+ Dict_putDict(preConf, String_CONST("logging"), logging, allocator);
+ }
#define CONFIG_BUFF_SIZE 1024
uint8_t buff[CONFIG_BUFF_SIZE] = {0};

0 comments on commit a0cbee7

Please sign in to comment.