Blame common/scopedlogger.h
|
Packit |
1244b8 |
/*
|
|
Packit |
1244b8 |
* Copyright (C) 2014 Intel Corporation. All rights reserved.
|
|
Packit |
1244b8 |
*
|
|
Packit |
1244b8 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit |
1244b8 |
* you may not use this file except in compliance with the License.
|
|
Packit |
1244b8 |
* You may obtain a copy of the License at
|
|
Packit |
1244b8 |
*
|
|
Packit |
1244b8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
1244b8 |
*
|
|
Packit |
1244b8 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
1244b8 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
1244b8 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
1244b8 |
* See the License for the specific language governing permissions and
|
|
Packit |
1244b8 |
* limitations under the License.
|
|
Packit |
1244b8 |
*/
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#ifndef scopedlogger_h
|
|
Packit |
1244b8 |
#define scopedlogger_h
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
/*it's expensive, disable it by default*/
|
|
Packit |
1244b8 |
#define DISABLE_SCOPED_LOGGER
|
|
Packit |
1244b8 |
#ifndef DISABLE_SCOPED_LOGGER
|
|
Packit |
1244b8 |
#include "log.h"
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
class ScopedLogger {
|
|
Packit |
1244b8 |
public:
|
|
Packit |
1244b8 |
ScopedLogger(const char *str)
|
|
Packit |
1244b8 |
{
|
|
Packit |
1244b8 |
m_str = str;
|
|
Packit |
1244b8 |
INFO("+%s", m_str);
|
|
Packit |
1244b8 |
}
|
|
Packit |
1244b8 |
~ScopedLogger()
|
|
Packit |
1244b8 |
{
|
|
Packit |
1244b8 |
INFO("-%s", m_str);
|
|
Packit |
1244b8 |
}
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
private:
|
|
Packit |
1244b8 |
const char *m_str;
|
|
Packit |
1244b8 |
};
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#define FUNC_ENTER() ScopedLogger __func_loggger__(__func__)
|
|
Packit |
1244b8 |
#else
|
|
Packit |
1244b8 |
#define FUNC_ENTER()
|
|
Packit |
1244b8 |
#endif
|
|
Packit |
1244b8 |
|
|
Packit |
1244b8 |
#endif //scopedlogger_h
|