diff options
Diffstat (limited to 'runtimes/neurun/src/util/logging.h')
-rw-r--r-- | runtimes/neurun/src/util/logging.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/runtimes/neurun/src/util/logging.h b/runtimes/neurun/src/util/logging.h new file mode 100644 index 000000000..62d563967 --- /dev/null +++ b/runtimes/neurun/src/util/logging.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __NEURUN_UTIL_LOGGING_H__ +#define __NEURUN_UTIL_LOGGING_H__ + +#include <iostream> + +namespace neurun +{ +namespace util +{ +namespace logging +{ + +class Context +{ +public: + Context() : _enabled{false} + { + auto env = std::getenv("NEURUN_LOG_ENABLE"); + + if (env && std::atoi(env) > 0) + { + _enabled = true; + } + } + +public: + bool enabled(void) const { return _enabled; } + +private: + bool _enabled; +}; + +static Context ctx; + +} // namespace logging +} // namespace util +} // namespace neurun + +#define VERBOSE(name) \ + if (::neurun::util::logging::ctx.enabled()) \ + std::cout << "[" << #name << "] " + +#endif // __NEURUN_UTIL_LOGGING_H__ |