#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <pthread.h>
Go to the source code of this file.
Classes | |
struct | logger_impl::streambuff_tls_entry |
class | file_logger |
struct | log_dispatch< dostuff > |
struct | log_dispatch< true > |
struct | log_dispatch< false > |
struct | null_stream |
struct | log_stream_dispatch< dostuff > |
struct | log_stream_dispatch< true > |
struct | log_stream_dispatch< false > |
Macros | |
#define | LOG_NONE 5 |
#define | LOG_FATAL 4 |
#define | LOG_ERROR 3 |
#define | LOG_WARNING 2 |
#define | LOG_INFO 1 |
#define | LOG_DEBUG 0 |
#define | OUTPUTLEVEL LOG_DEBUG |
#define | COLOROUTPUT |
If set, logs to screen will be printed in color. | |
#define | logger(lvl, fmt,...) (log_dispatch<(lvl >= OUTPUTLEVEL)>::exec(lvl,__FILE__, __func__ ,__LINE__,fmt,##__VA_ARGS__)) |
#define | logbuf(lvl, buf, len) |
#define | logstream(lvl) (log_stream_dispatch<(lvl >= OUTPUTLEVEL)>::exec(lvl,__FILE__, __func__ ,__LINE__) ) |
#define | RESET 0 |
#define | BRIGHT 1 |
#define | DIM 2 |
#define | UNDERLINE 3 |
#define | BLINK 4 |
#define | REVERSE 7 |
#define | HIDDEN 8 |
#define | BLACK 0 |
#define | RED 1 |
#define | GREEN 2 |
#define | YELLOW 3 |
#define | BLUE 4 |
#define | MAGENTA 5 |
#define | CYAN 6 |
#define | WHITE 7 |
Functions | |
void | textcolor (FILE *handle, int attr, int fg) |
void | reset_color (FILE *handle) |
Copyright (c) 2009 Carnegie Mellon University. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
For more about this software visit:
http://www.graphlab.ml.cmu.edu
Usage: First include logger.hpp. To logger, use the logger() function There are 2 output levels. A "soft" output level which is set by calling global_logger.set_log_level(), as well as a "hard" output level OUTPUTLEVEL which is set in the source code (logger.h).
when you call "logger()" with a loglevel and if the loglevel is greater than both of the output levels, the string will be written. written to a logger file. Otherwise, logger() has no effect.
The difference between the hard level and the soft level is that the soft level can be changed at runtime, while the hard level optimizes away logging calls at compile time.
#define LOG_DEBUG 0 |
Debugging purposes only
#define LOG_ERROR 3 |
Used for errors which are recoverable within the scope of the function
#define LOG_FATAL 4 |
NOTICE: This file taken from GraphLab (as stated in the license above). I have merged the CPP and HPP files.
Used for fatal and probably irrecoverable conditions
#define LOG_INFO 1 |
Used for providing general useful information
#define LOG_NONE 5 |
OUTPUTLEVEL to LOG_NONE to disable logging
#define LOG_WARNING 2 |
Logs interesting conditions which are probably not fatal
#define logbuf | ( | lvl, | |
buf, | |||
len | |||
) |
#define logger | ( | lvl, | |
fmt, | |||
... | |||
) | (log_dispatch<(lvl >= OUTPUTLEVEL)>::exec(lvl,__FILE__, __func__ ,__LINE__,fmt,##__VA_ARGS__)) |
extracts the filename, line number and function name and calls _log. It will be optimized away if LOG_NONE is set This relies on a few compiler macros. As far as I know, these macros are pretty standard among most other C++ compilers.
#define OUTPUTLEVEL LOG_DEBUG |
The minimum level to logger at