clog

From ConformalOpenSource
Revision as of 12:38, 12 June 2013 by Dhill (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

clog (Copious Logger) is a library that provides various logging services. It can be used to log information to syslog or stderr at various levels of verbosenes. The user can define his/her own debug/verbosity flags to, at runtime, determine how verbose an application or daemon is.

Installation

On OpenBSD:

make obj
make depend
make
sudo make install

Example Use

        clog_init(1);

        if (clog_set_flags(CLOG_F_FILE | CLOG_F_FUNC | CLOG_F_LINE |
            CLOG_F_STDERR | CLOG_F_ENABLE | CLOG_F_DTIME))
                errx(1, "can't set clog flags");
        clog_set_mask(CLOGTEST_F_LEVEL1 | CLOGTEST_F_LEVEL2);

        CNDBG(CLOGTEST_F_LEVEL3, "not printed %s", "meh");
        CNDBG(CLOGTEST_F_LEVEL1, "printed %s", "meh");
        CDBG("dbg too %s", "DBG");

        if (clog_set_flags(CLOG_F_STDERR | CLOG_F_ENABLE | CLOG_F_DTIME | CLOG_F_DATE))
                errx(1, "can't clear clog flags");

        CNDBG(1, "moo %s", "meh");
        CDBG("dbg2 too %s", "feh");

        if (clog_set_flags(CLOG_F_STDERR | CLOG_F_ENABLE | CLOG_F_DATE | CLOG_F_SYSLOG | CLOG_F_DBGENABLE))
                errx(1, "can't clear clog flags");

        CNDBG(1, "bah %s", "lah");
        CDBG("dbg 3 too %s", "foo");

        CWARNX("OHNOES WARNING");
        CWARN("OHNOES WARNING with errno");
        CNFATAL(CLOGTEST_F_LEVEL3, "OHNOES FATAL");

        /* not reached */
        CWARNX("OHNOES WARNING not reached");


clog resources