vg
tools for working with variation graphs
Loading...
Searching...
No Matches
log.hpp File Reference
#include <string>
#include <iostream>

Classes

class  vg::cerrWrapper
class  vg::Logger

Namespaces

namespace  vg
namespace  vg::logging

Functions

cerrWrapper vg::logging::info (const std::string &context)
cerrWrapper vg::logging::warn (const std::string &context)
cerrWrapper vg::logging::error (const std::string &context)

Detailed Description

log.hpp: defines a basic logging system for vg. Shipped along with utility.hpp

There are three options here:

  • info(): do nothing but append a context string to the front of the log message. This is useful for logging progress messages. This is a generic logging utility.
  • warn(): emit a warning message with a given context
  • error(): emit an error message with a given context

Errors/warnings are output to std::cerr as: error[<context>] message warning[<context>] message where "context" is a string like "vg inject"

The error/warning functions exist to have a standardized error/warning format across the vg subcommands. You don't have to use them elsewhere, but it's a good idea to have consistent formatting.

These functions return a cerrWrapper object that behaves like a stream. You can stream things to it with operator<<, and when the object goes out of scope, it will exit the program with a failure code (in the case of error) or do nothing (in the case of warn() and info()).

Logging functions may either be accessed via logging::info/warn/error, or via a Logger object that is initialized with a context string.