2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of assert
26 #include <dpl/assert.h>
27 #include <dpl/colors.h>
28 #include <dpl/exception.h>
29 #include <dpl/log/wrt_log.h>
32 void AssertProc(const char *condition,
38 #define INTERNAL_LOG(message) \
40 std::ostringstream platformLog; \
41 platformLog << message; \
42 WrtLogE("%s", platformLog.str().c_str()); \
45 // Try to log failed assertion to log system
47 INTERNAL_LOG("########################################################################");
48 INTERNAL_LOG("### DPL assertion failed! ###");
49 INTERNAL_LOG("########################################################################");
50 INTERNAL_LOG("### Condition: " << condition);
51 INTERNAL_LOG("### File: " << file);
52 INTERNAL_LOG("### Line: " << line);
53 INTERNAL_LOG("### Function: " << function);
54 INTERNAL_LOG("########################################################################");
56 // Just ignore possible double errors
59 // print assertion message to stderr
60 fprintf(stderr, "Assert!! [%s:%s] %s\n", file, function, condition);
62 // Fail with c-library abort