Code Monkey home page Code Monkey logo

picolog's Introduction

picolog

A simple c++ log class that uses stream semantics.

Installation

Copy picolog.hpp into your projects include path. Done.

How to use

Either use the log function to get a reference to a Log instance using std::cout:

pico::log().d() << "This is message number " << 4 << std::endl;

Or create your own Log using a different ostream:

std::ofstream file;
file.open("test.txt");

pico::Log log(file);
log.d() << "This is a test" << std::endl;

// Don't forget to close the file when you are done with logging
file.close();

User types can easily be logged by overloading operator<<:

pico::Log& operator<<(Log& log, const UserType& u)
{
        return log << u.a << "," << u.b;
}

UserType u = { "test", 2.5f };
log().d() << "A user type: " << u << std::endl;

Build the example

You can use the Makefile and type make all or use a simple g++ command:

g++ -I. example.cpp -Wall -Wpedantic

License

picolog uses the zlib license that is shipped with the header file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.