attached is the google-glog port

Information for inst:glog-0.3.0

Comment:
c++ application-level logging

Description:
The glog library implements application-level logging. This library
provides logging APIs based on C++-style streams and various helper
macros.

Maintainer: Vincent Auclair <[email protected]>

WWW: http://code.google.com/p/google-glog/

It is missing a library to correctly dump the signal handlers.
one of these probably : execinfo, libunwind or ucontext

It requires google-gtest and google-gflags.
Comments ?
And same as for gtest, this was ported for the ACSEL, can it be
mentioned in the commit message.


Here is an example file (also attached) :

#include <glog/logging.h>
#include <gflags/gflags.h>
#include <cstddef>

int main(int ac, char **av) {
        // this is for glog
        google::InitGoogleLogging(av[0]);
        google::InstallFailureSignalHandler();
        // now for gflags
        google::ParseCommandLineFlags(&ac, &av, true);

        // normal log
        LOG(INFO) << "test info";
        LOG(WARNING) << "this is a warning";
        LOG(ERROR) << "this is a error";
        //LOG(FATAL) << "this stops the program"

        // verbose logging
        VLOG(1) << "log at level 1";
        VLOG(4) << "log at level 4";

        // debug logging
        DLOG(INFO) << "log if NDEBUG not defined"; // same for 
WARNING,ERROR,FATAL

        // conditional logging
        {
                int num_cookies = 20;
                LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
                // example taken from the website
        }

        // check macros (not controlled by NDEBUG)
        CHECK(true == true) << "or else the world ends";

        return EXIT_SUCCESS;
}

new...@glitter-band > g++ test.cpp -I/usr/local/include
-L/usr/local/lib -lglog -lgflags -o glog-test
/usr/lib/libstdc++.so.49.0: warning: strcpy() is almost always
misused, please use strlcpy()
/usr/lib/libstdc++.so.49.0: warning: strcat() is almost always
misused, please use strlcat()
new...@glitter-band > ./glog-test
E1231 13:38:15.125598 2185737216 test.cpp:15] this is a error
new...@glitter-band > ls /tmp/glog-test*
/tmp/glog-test
/tmp/glog-test.ERROR
/tmp/glog-test.INFO
/tmp/glog-test.WARNING
/tmp/glog-test.glitter-band.XXX.newton.log.ERROR.20091231-133815.13306
/tmp/glog-test.glitter-band.XXX.newton.log.INFO.20091231-133815.13306
/tmp/glog-test.glitter-band.XXX.newton.log.WARNING.20091231-133815.13306
new...@glitter-band > ./glog-test --help
// Only including glog flags here
  Flags from src/logging.cc:
    -alsologtoemail (log messages go to these email addresses in addition to
      logfiles) type: string default: ""
    -alsologtostderr (log messages go to stderr in addition to logfiles)
      type: bool default: false
    -log_backtrace_at (Emit a backtrace when logging at file:linenum.)
      type: string default: ""
    -log_dir (If specified, logfiles are written into this directory instead of
      the default logging directory.) type: string default: ""
    -log_link (Put additional links to the log files in this directory)
      type: string default: ""
    -log_prefix (Prepend the log prefix to the start of each log line)
      type: bool default: true
    -logbuflevel (Buffer log messages logged at this level or lower (-1 means
      don't buffer; 0 means buffer INFO only; ...)) type: int32 default: 0
    -logbufsecs (Buffer log messages for at most this many seconds) type: int32
      default: 30
    -logemaillevel (Email log messages logged at this level or higher (0 means
      email all; 3 means email FATAL only; ...)) type: int32 default: 999
    -logmailer (Mailer used to send logging email) type: string
      default: "/bin/mail"
    -logtostderr (log messages go to stderr instead of logfiles) type: bool
      default: false
    -max_log_size (approx. maximum log file size (in MB). A value of 0 will be
      silently overridden to 1.) type: int32 default: 1800
    -minloglevel (Messages logged at a lower level than this don't actually get
      logged anywhere) type: int32 default: 0
    -stderrthreshold (log messages at or above this level are copied to stderr
      in addition to logfiles.  This flag obsoletes --alsologtostderr.)
      type: int32 default: 2
    -stop_logging_if_full_disk (Stop attempting to log to disk if the disk is
      full.) type: bool default: false

  Flags from src/utilities.cc:
    -symbolize_stacktrace (Symbolize the stack trace in the tombstone)
      type: bool default: true

  Flags from src/vlog_is_on.cc:
    -v (Show all VLOG(m) messages for m <= this. Overridable by --vmodule.)
      type: int32 default: 0
    -vmodule (per-module verbose level. Argument is a comma-separated list of
      <module name>=<log level>. <module name> is a glob pattern, matched
      against the filename base (that is, name ignoring .cc/.h./-inl.h). <log
      level> overrides any value given by --v.) type: string default: ""

You can also log to syslog and send mails.


-- 
Vincent Auclair        -      auclair.vincent[ at ]gmail.com
(+33) 6 80 77 59 67

Attachment: glog.tar.gz
Description: GNU Zip compressed data

Attachment: test.cpp
Description: Binary data

Reply via email to