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
24 #include <dpl/assert.h>
25 #include <dpl/colors.h>
26 #include <dpl/log/log.h>
30 void AssertProc(const char *condition,
35 #define INTERNAL_LOG(message) \
38 std::ostringstream platformLog; \
39 platformLog << message; \
40 DPL::Log::LogSystemSingleton::Instance().Pedantic( \
41 platformLog.str().c_str(), \
42 __FILE__, __LINE__, __FUNCTION__); \
46 // Try to log failed assertion to log system
50 "################################################################################");
52 "### DPL assertion failed! ###");
54 "################################################################################");
55 INTERNAL_LOG("### Condition: " << condition);
56 INTERNAL_LOG("### File: " << file);
57 INTERNAL_LOG("### Line: " << line);
58 INTERNAL_LOG("### Function: " << function);
60 "################################################################################");
62 // Just ignore possible double errors
65 // print assertion message to stderr
66 fprintf(stderr, "Assert!! [%s:%s] %s\n", file, function, condition);
68 // Fail with c-library abort