Git Product home page Git Product logo

libprintfmt's Introduction

libprintfmt

wrapper for printf functions in C.

supports more file descriptors than only stdout and stderr. puts everything on stdout with known prefixes and colours

overrides fprintf, dprintf, and fprintf. check the header file for other wrapper functions.

compile with -DVERBOSITY=5 for highest trace level. file descriptor numbers lower than verbosity gets filtered away.

for user builds, i suggest -DVERBOSITY=2 since this includes stderr, but not anything above it.

build

: ${PREFIX:=${HOME:?}/.local}
mkdir -p "${PREFIX}/lib/debug"
cc -DVERBOSITY=2 -fPIC -shared -lncurses -o ${PREFIX}/lib/libprintfmt.so printfd.c
cc -DVERBOSITY=5 -fPIC -shared -lncurses -o ${PREFIX}/lib/debug/libprintfmt.so printfd.c

we build with ncurses to check for colours, it's usually installed anyway, so eh

alternatively you can slap on -DNO_COLOR to just disable colours altogether, which doesn't need ncurses; or specify -DFORCE_COLOR=8 to hardcode in support for 8 colours (which is what we need for our thing anyway)

usage

compile your programs with -L$(PREFIX)/lib -lprintfmt, and make sure to #include <printfd.h> in them

run your programs with LD_LIBRARY_PATH= set to either ${PREFIX}/lib/debug or ${PREFIX}/lib or whatever

you may want to place the libprintfmt.so on a well-known path, or link it statically. up to you tbh

showcase

example screenshot

libprintfmt's People

Contributors

mazunki avatar

Watchers

 avatar

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.