libcruft-util/tools/log.cpp

37 lines
771 B
C++
Raw Permalink Normal View History

2019-10-10 15:11:02 +11:00
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2019, Danny Robson <danny@nerdcruft.net>
*/
#include <cruft/util/log.hpp>
2019-10-10 15:11:02 +11:00
#include <iostream>
#include <cstdlib>
enum {
ARG_SELF,
ARG_LEVEL,
ARG_VALUE,
2019-10-10 15:11:02 +11:00
NUM_ARGS,
2019-10-10 15:11:02 +11:00
};
int main (int const argc, char const **argv)
{
if (argc < NUM_ARGS) {
fmt::print (stderr, "usage {} <level> <string>\n", argv[ARG_SELF]);
2019-10-10 15:11:02 +11:00
return EXIT_FAILURE;
}
auto const level = cruft::log::to_level (argv[ARG_LEVEL]);
auto const value = argv[ARG_VALUE];
2019-10-10 15:11:02 +11:00
cruft::log::write (level, "{}", value);
2019-10-10 15:11:02 +11:00
return EXIT_SUCCESS;
}