@@ -43,34 +43,30 @@ using namespace OpenSim;
43
43
// completely initialized before that happens the first time.
44
44
45
45
// Initialize a logger
46
- static void initializeLogger (spdlog::logger& l, const char * pattern) {
47
- l.set_level (spdlog::level::info);
48
- l.flush_on (spdlog::level::info);
49
- l.set_pattern (pattern);
46
+ static std::shared_ptr<spdlog::logger> initializeLogger (
47
+ std::shared_ptr<spdlog::logger> l,
48
+ const char * pattern)
49
+ {
50
+ l->set_level (spdlog::level::info);
51
+ l->flush_on (spdlog::level::info);
52
+ l->set_pattern (pattern);
53
+ return l;
50
54
}
51
55
52
56
// Return a reference to the static cout logger object, allocating and
53
57
// initializing it on the first call.
54
58
static spdlog::logger& coutLoggerInternal () {
55
- static std::shared_ptr<spdlog::logger> l = spdlog::stdout_color_mt (" cout" );
56
- static bool first = true ;
57
- if (first) {
58
- initializeLogger (*l, " %v" );
59
- first = false ;
60
- }
61
- return *l;
59
+ static std::shared_ptr<spdlog::logger> l =
60
+ initializeLogger (spdlog::stdout_color_mt (" cout" ), " %v" );
61
+ return *l;
62
62
}
63
63
64
64
// Return a reference to the static default logger object, allocating and
65
65
// initializing it on the first call.
66
66
static spdlog::logger& defaultLoggerInternal () {
67
- static std::shared_ptr<spdlog::logger> l = spdlog::default_logger ();
68
- static bool first = true ;
69
- if (first) {
70
- initializeLogger (*l, " [%l] %v" );
71
- first = false ;
72
- }
73
- return *l;
67
+ static std::shared_ptr<spdlog::logger> l =
68
+ initializeLogger (spdlog::default_logger (), " [%l] %v" );
69
+ return *l;
74
70
}
75
71
76
72
// the file log sink (e.g. `opensim.log`) is lazily initialized.
0 commit comments