MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / serverLogFromHandler

Function serverLogFromHandler

src/server.cpp:1276–1296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1274# endif
1275#endif
1276void serverLogFromHandler(int level, const char *msg) {
1277 int fd;
1278 int log_to_stdout = g_pserver->logfile[0] == '\0';
1279 char buf[64];
1280
1281 if ((level&0xff) < cserver.verbosity || (log_to_stdout && cserver.daemonize))
1282 return;
1283 fd = log_to_stdout ? STDOUT_FILENO :
1284 open(g_pserver->logfile, O_APPEND|O_CREAT|O_WRONLY, 0644);
1285 if (fd == -1) return;
1286 ll2string(buf,sizeof(buf),getpid());
1287 if (write(fd,buf,strlen(buf)) == -1) goto err;
1288 if (write(fd,":signal-handler (",17) == -1) goto err;
1289 ll2string(buf,sizeof(buf),time(NULL));
1290 if (write(fd,buf,strlen(buf)) == -1) goto err;
1291 if (write(fd,") ",2) == -1) goto err;
1292 if (write(fd,msg,strlen(msg)) == -1) goto err;
1293 if (write(fd,"\n",1) == -1) goto err;
1294err:
1295 if (!log_to_stdout) close(fd);
1296}
1297
1298/* Return the UNIX time in microseconds */
1299long long ustime(void) {

Callers 3

sigShutdownHandlerFunction · 0.85
sigKillChildHandlerFunction · 0.85
watchdogSignalHandlerFunction · 0.85

Calls 1

ll2stringFunction · 0.85

Tested by

no test coverage detected