2018-05-10 09:46:34 +03:00
|
|
|
// Copyright 2018 Slightech 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.
|
2018-09-04 10:12:04 +03:00
|
|
|
#ifndef MYNTEYE_LOGGER_H_
|
|
|
|
#define MYNTEYE_LOGGER_H_
|
2018-04-04 05:50:27 +03:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-04 11:07:36 +03:00
|
|
|
#ifdef WITH_GLOG
|
|
|
|
|
2018-04-04 05:50:27 +03:00
|
|
|
#include <glog/logging.h>
|
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/** Helper to init glog with args. */
|
2018-04-04 05:50:27 +03:00
|
|
|
struct glog_init {
|
2018-05-16 05:31:31 +03:00
|
|
|
/**
|
|
|
|
* Init glog with args in constructor, and shutdown it in destructor.
|
|
|
|
*/
|
|
|
|
glog_init(int argc, char *argv[]) {
|
|
|
|
(void)argc;
|
|
|
|
|
2018-07-19 10:46:19 +03:00
|
|
|
// Set whether log messages go to stderr instead of logfiles
|
|
|
|
FLAGS_logtostderr = true;
|
|
|
|
|
|
|
|
// Set whether log messages go to stderr in addition to logfiles.
|
|
|
|
// FLAGS_alsologtostderr = true;
|
|
|
|
|
|
|
|
// Set color messages logged to stderr (if supported by terminal).
|
2018-04-04 05:50:27 +03:00
|
|
|
FLAGS_colorlogtostderr = true;
|
|
|
|
|
2018-07-19 10:46:19 +03:00
|
|
|
// Log suppression level: messages logged at a lower level than this
|
|
|
|
// are suppressed.
|
2018-08-01 10:11:47 +03:00
|
|
|
FLAGS_minloglevel = google::GLOG_INFO;
|
2018-07-19 10:46:19 +03:00
|
|
|
|
|
|
|
// If specified, logfiles are written into this directory instead of the
|
|
|
|
// default logging directory.
|
|
|
|
FLAGS_log_dir = ".";
|
|
|
|
|
|
|
|
// Sets the maximum log file size (in MB).
|
2018-09-04 12:18:35 +03:00
|
|
|
FLAGS_max_log_size = 8;
|
2018-07-19 10:46:19 +03:00
|
|
|
|
|
|
|
// Sets whether to avoid logging to the disk if the disk is full.
|
2018-04-04 05:50:27 +03:00
|
|
|
FLAGS_stop_logging_if_full_disk = true;
|
|
|
|
|
2018-07-19 10:46:19 +03:00
|
|
|
// Show all VLOG(m) messages for m <= this.
|
2018-04-08 17:35:49 +03:00
|
|
|
// FLAGS_v = 2;
|
2018-04-04 05:50:27 +03:00
|
|
|
|
|
|
|
google::InitGoogleLogging(argv[0]);
|
|
|
|
|
|
|
|
VLOG(2) << __func__;
|
|
|
|
}
|
|
|
|
|
|
|
|
~glog_init() {
|
|
|
|
VLOG(2) << __func__;
|
|
|
|
google::ShutdownGoogleLogging();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-04 11:07:36 +03:00
|
|
|
#else
|
|
|
|
|
|
|
|
struct glog_init {
|
|
|
|
glog_init(int argc, char *argv[]) {
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2018-09-04 12:00:18 +03:00
|
|
|
// Do nothing.
|
2018-09-04 11:07:36 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-14 11:25:41 +02:00
|
|
|
#include "mynteye/mynteye.h"
|
|
|
|
|
|
|
|
#ifdef WITH_CAM_MODELS
|
|
|
|
|
|
|
|
#define MAX_LOG_LEVEL google::INFO
|
|
|
|
|
|
|
|
// include ceres miniglog
|
|
|
|
#include "glog/logging.h"
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-09-11 05:19:25 +03:00
|
|
|
#define MYNTEYE_MAX_LOG_LEVEL google::INFO
|
2019-01-16 04:38:46 +02:00
|
|
|
// #define MYNTEYE_MAX_LOG_LEVEL 2
|
2018-09-04 12:31:21 +03:00
|
|
|
|
2018-09-04 12:00:18 +03:00
|
|
|
#include "mynteye/miniglog.h"
|
2018-09-04 11:07:36 +03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-01-14 11:25:41 +02:00
|
|
|
#endif
|
|
|
|
|
2018-09-04 10:12:04 +03:00
|
|
|
#endif // MYNTEYE_LOGGER_H_
|