File tree Expand file tree Collapse file tree 4 files changed +99
-0
lines changed
Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // assert.cpp
3+ // OpenBox
4+
5+ #include " assert.hpp"
6+ #include " log.hpp"
7+
8+ char * error_message = nullptr ;
9+
10+ namespace OB {
11+ void precondition_failure (const char *format, ...) {
12+ char * s = nullptr ;
13+ va_list va;
14+ va_start (va, format);
15+ vasprintf (&s, format, va);
16+ va_end (va);
17+ if (s != nullptr ) {
18+ #if OB_TARGET_OS_DARWIN
19+ os_log_error (error_log (), " precondition failure: %s" , s);
20+ #endif /* OB_TARGET_OS_DARWIN */
21+ if (error_message == nullptr ) {
22+ asprintf (&error_message, " OpenGraph precondition failure: %s.\n " , s);
23+ }
24+ free (s);
25+ }
26+ abort ();
27+ }
28+
29+ void non_fatal_precondition_failure (const char *format, ...) {
30+ char * s = nullptr ;
31+ va_list va;
32+ va_start (va, format);
33+ vasprintf (&s, format, va);
34+ va_end (va);
35+ if (s != nullptr ) {
36+ #if OB_TARGET_OS_DARWIN
37+ os_log_fault (error_log (), " precondition failure: %s" , s);
38+ #endif /* OB_TARGET_OS_DARWIN */
39+ free (s);
40+ }
41+ return ;
42+ }
43+ } /* OB */
Original file line number Diff line number Diff line change 1+ //
2+ // assert.hpp
3+ // OpenBox
4+
5+ #ifndef assert_hpp
6+ #define assert_hpp
7+
8+ #include " OBBase.h"
9+
10+ namespace OB {
11+ void precondition_failure (const char *format, ...) __cold __dead2;
12+ void non_fatal_precondition_failure (const char *format, ...);
13+ } /* OB */
14+
15+ #endif /* assert_hpp */
Original file line number Diff line number Diff line change 1+ //
2+ // OGLog.cpp
3+ // OpenBox
4+
5+ #include " log.hpp"
6+
7+ #if OB_TARGET_OS_DARWIN
8+
9+ namespace OB {
10+ os_log_t misc_log () {
11+ static os_log_t log = os_log_create (" org.openswiftuiproject.openbox" , " misc" );
12+ return log;
13+ }
14+ os_log_t error_log () {
15+ static os_log_t log = os_log_create (" org.openswiftuiproject.openbox" , " error" );
16+ return log;
17+ }
18+ } /* OB */
19+
20+ #endif /* OB_TARGET_OS_DARWIN */
Original file line number Diff line number Diff line change 1+ //
2+ // log.hpp
3+ // OpenBox
4+
5+ #ifndef log_hpp
6+ #define log_hpp
7+
8+ #include " OBBase.h"
9+
10+ #if OB_TARGET_OS_DARWIN
11+
12+ #include < os/log.h>
13+
14+ namespace OB {
15+ os_log_t misc_log ();
16+ os_log_t error_log ();
17+ } /* OB */
18+
19+ #endif /* OB_TARGET_OS_DARWIN */
20+
21+ #endif /* log_hpp */
You can’t perform that action at this time.
0 commit comments