mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Just a few minor overloads and usability tweaks to the logger interface.
This commit is contained in:
parent
69e5340ccd
commit
ff55b02956
@ -36,10 +36,21 @@ namespace dlib
|
||||
name[19] = '\0';
|
||||
}
|
||||
|
||||
bool operator< (const log_level& rhs) const { return priority < rhs.priority; }
|
||||
bool operator<=(const log_level& rhs) const { return priority <= rhs.priority; }
|
||||
bool operator> (const log_level& rhs) const { return priority > rhs.priority; }
|
||||
bool operator>=(const log_level& rhs) const { return priority >= rhs.priority; }
|
||||
|
||||
int priority;
|
||||
char name[20];
|
||||
};
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& out, const log_level& item)
|
||||
{
|
||||
out << item.name;
|
||||
return out;
|
||||
}
|
||||
|
||||
const log_level LALL (std::numeric_limits<int>::min(),"ALL");
|
||||
const log_level LNONE (std::numeric_limits<int>::max(),"NONE");
|
||||
const log_level LTRACE(-100,"TRACE");
|
||||
@ -79,6 +90,16 @@ namespace dlib
|
||||
const char* message_to_log)
|
||||
);
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
void set_all_logging_output_hooks (
|
||||
T& object
|
||||
)
|
||||
{
|
||||
set_all_logging_output_hooks(object, &T::log);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class logger
|
||||
|
@ -35,10 +35,22 @@ namespace dlib
|
||||
is null terminated.
|
||||
!*/
|
||||
|
||||
bool operator< (const log_level& rhs) const { return priority < rhs.priority; }
|
||||
bool operator<=(const log_level& rhs) const { return priority <= rhs.priority; }
|
||||
bool operator> (const log_level& rhs) const { return priority > rhs.priority; }
|
||||
bool operator>=(const log_level& rhs) const { return priority >= rhs.priority; }
|
||||
|
||||
int priority;
|
||||
char name[20];
|
||||
};
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& out, const log_level& item);
|
||||
/*!
|
||||
ensures
|
||||
- performs out << item.name
|
||||
- returns out
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
const log_level LALL (std::numeric_limits<int>::min(),"ALL");
|
||||
@ -89,6 +101,17 @@ namespace dlib
|
||||
- std::bad_alloc
|
||||
!*/
|
||||
|
||||
template <
|
||||
typename T
|
||||
>
|
||||
void set_all_logging_output_hooks (
|
||||
T& object
|
||||
);
|
||||
/*!
|
||||
ensures
|
||||
- calls set_all_logging_output_hooks(object, &T::log);
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
void set_all_logging_levels (
|
||||
|
Loading…
Reference in New Issue
Block a user