-
Couldn't load subscription status.
- Fork 1.5k
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedNeeds help from a contributorNeeds help from a contributorquestionFurther information is requestedFurther information is requested
Description
Question
Lines 67 to 74 in 95edd11
| /** | |
| * These functions won't output header information such as __FUNCTION__, | |
| * The user should control these information | |
| * If the header information should be outputed | |
| * please use LOG_PANIC, LOG_ERROR ... | |
| */ | |
| template <class T> | |
| Log &operator<<(T message); |
这个地方注释说不会输出header信息,但这些函数的定义中都调用了
Log::out()方法。Lines 236 to 242 in 95edd11
| template <class T> | |
| Log &Log::operator<<(T msg) | |
| { | |
| // at this time, the input level is the default log level | |
| out(console_level_, log_level_, msg); | |
| return *this; | |
| } |
而
Log::out()方法中使用了宏LOG_HEAD (290行)。Lines 281 to 314 in 95edd11
| int Log::out(const LOG_LEVEL console_level, const LOG_LEVEL log_level, T &msg) | |
| { | |
| bool locked = false; | |
| if (console_level < LOG_LEVEL_PANIC || console_level > console_level_ || log_level < LOG_LEVEL_PANIC || | |
| log_level > log_level_) { | |
| return LOG_STATUS_OK; | |
| } | |
| try { | |
| char prefix[ONE_KILO] = {0}; | |
| LOG_HEAD(prefix, log_level); | |
| if (LOG_LEVEL_PANIC <= console_level && console_level <= console_level_) { | |
| cout << prefix_map_[console_level] << msg; | |
| } | |
| if (LOG_LEVEL_PANIC <= log_level && log_level <= log_level_) { | |
| pthread_mutex_lock(&lock_); | |
| locked = true; | |
| ofs_ << prefix; | |
| ofs_ << msg; | |
| ofs_.flush(); | |
| log_line_++; | |
| pthread_mutex_unlock(&lock_); | |
| locked = false; | |
| } | |
| } catch (exception &e) { | |
| if (locked) { | |
| pthread_mutex_unlock(&lock_); | |
| } | |
| cerr << e.what() << endl; | |
| return LOG_STATUS_ERR; | |
| } | |
| return LOG_STATUS_OK; | |
| } |
注释是正确的吗?
nautaa
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedNeeds help from a contributorNeeds help from a contributorquestionFurther information is requestedFurther information is requested