Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
Change-Id: I652b3dab10459326ea6c82323779c134a93e8d97
  • Loading branch information
zhangyuanlong committed Oct 9, 2020
1 parent 3e82ae0 commit f4c0a93
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ LOG_WARN("Some warning...");
LOG_ERROR("Recv data error, errorNO=%d.", ::WSAGetLastError());
```

关于 **CIULog** 这个日志模块类,如果读者要想实际运行查看效果,可以从链接(https://github.com/baloonwj/flamingo/tree/master/flamingoclient)下载完整的项目代码来运行。该日志输出效果如下:
关于 **CIULog** 这个日志模块类,如果读者要想实际运行查看效果,可以从链接(https://github.com/baloonwj/flamingo/tree/master/flamingoclient )下载完整的项目代码来运行。该日志输出效果如下:

```
[2018-11-09 23:52:54:0826][INFO][ThreadID: 7252][bool __thiscall CIUSocket::Login(const char *,const char *,int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &):1107]Request logon: Account=zhangy, Password=*****, Status=76283204, LoginType=1.
Expand All @@ -475,7 +475,7 @@ LOG_ERROR("Recv data error, errorNO=%d.", ::WSAGetLastError());

在类 Unix 系统上(包括 Linux),同一个进程内针对同一个 **FILE*** 的操作是线程安全的,也就是说,在这类操作系统上得到的日志结果 A、B、C 各个字母组一定是连续在一起,也就是说最终得到的日志内容可能是 “**AAAAACCCCCBBBBB**” 或 “**AAAAABBBBBCCCCC**” 等这种连续的格式,绝不会出现 A、B、C 字母交错相间的现象。

而在Windows系统上,对于 **FILE*** 的操作并不是线程安全的。但是笔者做了大量实验,在 Windows 系统上也没有出现这种 A、B、C 字母相间的现象。(关于这个问题的讨论,可以参考这里:https://www.zhihu.com/question/40472431)
而在Windows系统上,对于 **FILE*** 的操作并不是线程安全的。但是笔者做了大量实验,在 Windows 系统上也没有出现这种 A、B、C 字母相间的现象。(关于这个问题的讨论,可以参考这里:https://www.zhihu.com/question/40472431

这种同步日志的实现方式,一般用于低频写日志的软件系统中(如客户端软件),所以我可以认为这种多线程同时写日志到一个文件中是可行的。

Expand Down

0 comments on commit f4c0a93

Please sign in to comment.