MCPcopy Create free account
hub / github.com/chenshuo/muduo / getFileName

Method getFileName

examples/ace/logging/server.cc:35–54  ·  view source on GitHub ↗

FIXME: duplicate code LogFile or use LogFile instead

Source from the content-addressed store, hash-verified

33 // FIXME: duplicate code LogFile
34 // or use LogFile instead
35 string getFileName(const TcpConnectionPtr& conn)
36 {
37 string filename;
38 filename += conn->peerAddress().toIp();
39
40 char timebuf[32];
41 struct tm tm;
42 time_t now = time(NULL);
43 gmtime_r(&now, &tm); // FIXME: localtime_r ?
44 strftime(timebuf, sizeof timebuf, ".%Y%m%d-%H%M%S.", &tm);
45 filename += timebuf;
46
47 char buf[32];
48 snprintf(buf, sizeof buf, "%d", globalCount_.incrementAndGet());
49 filename += buf;
50
51 filename += ".log";
52 LOG_INFO << "Session of " << conn->name() << " file " << filename;
53 return filename;
54 }
55
56 void onMessage(const TcpConnectionPtr& conn,
57 const MessagePtr& message,

Callers

nothing calls this directly

Calls 2

incrementAndGetMethod · 0.80
toIpMethod · 0.45

Tested by

no test coverage detected