-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Created by jxq on 19-11-18. | ||
// | ||
|
||
#include "../AsyncLogging.h" | ||
#include "../Logging.h" | ||
|
||
using namespace muduo; | ||
|
||
AsyncLogging* logptr = NULL; | ||
|
||
void asyncoutput(const char* msg, int len) | ||
{ | ||
logptr->append(msg, len); // 前台进程传递日志 | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
LOG_INFO << "hello"; | ||
char name[256]; | ||
strcpy(name, argv[0]); | ||
AsyncLogging asynclog("asynclog", 500*1000*1000); | ||
asynclog.start(); | ||
|
||
logptr = &asynclog; | ||
Logger::setOutput(asyncoutput); | ||
for (int i = 0; i < 10; ++i) | ||
{ | ||
LOG_INFO << "ASYNC LOG"; | ||
struct timespec ts = {0, 500*1000*1000}; | ||
nanosleep(&ts, NULL); | ||
}; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters