Skip to content
Snippets Groups Projects
Unverified Commit 0d7d91b7 authored by Stuart Sides's avatar Stuart Sides Committed by GitHub
Browse files

Merge pull request #325 from jessemapel/std_logging

Added the ability to log to standard out and standard error
parents aa9b736d ce82ca6c
Branches
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ endif() ...@@ -17,6 +17,7 @@ endif()
option(USGSCSM_EXTERNAL_DEPS "If the library should be built with external or embedded dependencies" OFF) option(USGSCSM_EXTERNAL_DEPS "If the library should be built with external or embedded dependencies" OFF)
if(USGSCSM_EXTERNAL_DEPS) if(USGSCSM_EXTERNAL_DEPS)
message(STATUS "Using external dependencies")
# CSM API library # CSM API library
find_path(CSM_INCLUDE_DIR NAMES "csm.h" find_path(CSM_INCLUDE_DIR NAMES "csm.h"
PATH_SUFFIXES "csm" PATH_SUFFIXES "csm"
...@@ -32,6 +33,7 @@ if(USGSCSM_EXTERNAL_DEPS) ...@@ -32,6 +33,7 @@ if(USGSCSM_EXTERNAL_DEPS)
find_package(ale REQUIRED) find_package(ale REQUIRED)
set(ALE_TARGET ale::ale) set(ALE_TARGET ale::ale)
else() else()
message(STATUS "Using embedded dependencies")
# CSM API library # CSM API library
add_subdirectory(csm) add_subdirectory(csm)
set(CSM_INCLUDE_DIR /csm) set(CSM_INCLUDE_DIR /csm)
......
# CSM-CameraModel # USGSCSM
Community Sensor Model (CSM) compliant sensor models created by USGS Astrogeology Community Sensor Model (CSM) compliant sensor models created by USGS Astrogeology
Science Center. Science Center.
CSM-CameraModel contains two different sensor models. The first, is a generic USGSCSM contains three different sensor models. The first, is a generic
framing camera model written from scratch. The second is a generic line scan framing camera model written from scratch. The second is a generic line scan
camera model based on code from BAE Systems Information and Electronic Systems camera model based on code from BAE Systems Information and Electronic Systems
Integration Inc. Integration Inc. The third is a generic SAR sensor model.
## Using CSM-CameraModel ## Using USGSCSM
This library is a CSM plugin library that is intended to be dynamically loaded This library is a CSM plugin library that is intended to be dynamically loaded
at run time along side the at run time along side the
...@@ -30,6 +30,16 @@ server for generating these, ...@@ -30,6 +30,16 @@ server for generating these,
[pfeffernusse](https://github.com/USGS-Astrogeology/pfeffernusse). The swagger [pfeffernusse](https://github.com/USGS-Astrogeology/pfeffernusse). The swagger
specification is located on specification is located on
[swaggerhub](https://app.swaggerhub.com/apis/USGS-Astro/pfeffernusse2/0.1.4-oas3). [swaggerhub](https://app.swaggerhub.com/apis/USGS-Astro/pfeffernusse2/0.1.4-oas3).
You can also use [ALE](https://github.com/USGS-Astrogeology/ale) directly with
metakernels to generate the auxiliary JSON file.
## Enabling logging
You can enable logging of the internal operations in the sensor models by setting
the `USGSCSM_LOG_FILE` environment variable to the file you would like to log to.
You can also log to standard out by setting it to `stdout` or standard error
by setting it to `stderr`. Note that these logs can become quite large, multiple
GBs.
--- ---
...@@ -42,28 +52,43 @@ specification is located on ...@@ -42,28 +52,43 @@ specification is located on
This repository has all of its external c++ dependencies included in it. The This repository has all of its external c++ dependencies included in it. The
excellent header-only JSON library excellent header-only JSON library
[JSON for Modern C++](https://github.com/nlohmann/json) is included directly in [JSON for Modern C++](https://github.com/nlohmann/json) is included directly in
the source code. The other two dependencies, the CSM API library, and gtest the source code. The other three dependencies, The Abstraction Library for
are included as git submodules. When you clone this library make sure you add Ephemerides, the CSM API library, and googletest are included as git submodules.
the `--recursive` flag to your `git clone` command. Alaterntively, you can run When you clone this library make sure you add the `--recursive` flag to your
`git submodule update --init --recursive` after cloning. The library can also be `git clone` command. Alterntively, you can run
compiled against an installed versions of the CSM API by setting the BUILD_CSM `git submodule update --init --recursive` after cloning.
flag to OFF during cmake configuration.
You can also install the build requirements using Conda with the provided
`environment.yml` file. The following commands will create a new environment
to build against. Note that googletest cannot be installed via anaconda and must
be available within the source code. You can remove the googletest dependency
by disabling the tests.
## Building CSM-CameraModel ```
conda env create -n usgscsm -f environment.yml -y
```
CSM-CameraModel uses a standard cmake build system. To compile the library, and ## Building USGSCSM
USGSCSM uses a standard cmake build system. To compile the library and
tests use the following commands: tests use the following commands:
1. `mkdir build && cd build` 1. `mkdir build && cd build`
2. `cmake .. && cmake --build .` 2. `cmake .. && cmake --build .`
## Testing CSM-CameraModel If you are using external dependencies via Conda or system level installations
add the `-DUSGSCSM_EXTERNAL_DEPS=ON` flag to the cmake command.
You can also disable the tests and the googletest dependency by adding the
`-DUSGSCSM_BUILD_TESTS=OFF` flag to the cmake command.
## Testing USGSCSM
All of the tests for CSM-CameraModel are written in the googletests framework All of the tests for USGSCSM are written in the googletests framework
and are run via ctest. To run all of the tests simply run `ctest` in the build. and are run via ctest. To run all of the tests simply run `ctest` in the build.
All of the tests are purposefully written to use generic data that values have All of the tests are purposefully written to use generic data that values have
been hand validated for. This data can be found under `tests/data`. been hand validated. This data can be found under `tests/data`.
## Code Style ## Code Style
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <Version.h> #include <Version.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
class UsgsAstroPlugin : public csm::Plugin { class UsgsAstroPlugin : public csm::Plugin {
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include <csm.h> #include <csm.h>
#include <math.h> #include <math.h>
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;
...@@ -50,12 +53,22 @@ UsgsAstroPlugin::UsgsAstroPlugin() { ...@@ -50,12 +53,22 @@ UsgsAstroPlugin::UsgsAstroPlugin() {
std::shared_ptr<spdlog::logger> m_logger = spdlog::get("usgscsm_logger"); std::shared_ptr<spdlog::logger> m_logger = spdlog::get("usgscsm_logger");
if (!m_logger) { if (!m_logger) {
if (logFile == "stdout") {
std::shared_ptr<spdlog::logger> m_logger =
spdlog::stdout_color_mt("usgscsm_logger");
}
else if (logFile == "stderr") {
std::shared_ptr<spdlog::logger> m_logger =
spdlog::stderr_color_mt("usgscsm_logger");
}
else {
std::shared_ptr<spdlog::logger> m_logger = std::shared_ptr<spdlog::logger> m_logger =
spdlog::basic_logger_mt("usgscsm_logger", logFile); spdlog::basic_logger_mt("usgscsm_logger", logFile);
} }
} }
} }
} }
}
UsgsAstroPlugin::~UsgsAstroPlugin() {} UsgsAstroPlugin::~UsgsAstroPlugin() {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment