182 va_start(vl, msgFormat);
183 std::vsprintf(
buffer, msgFormat, vl);
208 if (
log.m_file == NULL) {
209 #pragma omp critical(GLog_insert_logger)
228 std::ifstream file(
filename.
url().c_str(), std::ios::in);
233 while(std::getline(file,line)) {
234 #pragma omp critical(GLog_insert_logger)
298 std::ostringstream oss;
321 std::ostringstream oss;
367 std::ostringstream oss;
390 std::ostringstream oss;
413 std::ostringstream oss;
480 #pragma omp critical(GLog_flush)
514 #pragma omp critical(GLog_open)
541 #pragma omp critical(GLog_open)
622 if (
log.m_file != NULL) {
623 #pragma omp critical(GLog_copy_members)
624 m_file = fdopen(dup(fileno(
log.m_file)),
"a");
668 #pragma omp critical(GLog_flush)
682 std::size_t pos =
m_buffer.find_first_of(
"\n", 0);
683 if (pos == std::string::npos) {
689 line =
m_buffer.substr(0, pos) +
"\n";
696 std::fprintf(
m_file,
"%s", line.c_str());
737 text =
"| " + arg +
" |";
738 frame = (level == 1) ?
"+" +
gammalib::fill(
"=", text.length()-2) +
"+"
742 text =
"=== " + arg +
" ===";
749 if (frame.length() > 0) {
753 if (text.length() > 0) {
757 if (frame.length() > 0) {
811 #pragma omp critical(GLog_append)
814 std::string arg = string;
828 std::size_t pos = arg.find_first_of(
"\n",0);
831 while (pos != std::string::npos && pos < arg.size()-1) {
834 std::string pre =
prefix();
835 arg.insert(pos+1, pre);
838 pos = arg.find_first_of(
"\n",pos+1+pre.size());
Information logger class definition.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear file name.
Information logger interface definition.
int m_max_length
Maximum buffer length.
void free_members(void)
Delete class members.
void append(const std::string &string)
Append string to the buffer.
virtual ~GLog(void)
Destructor.
bool m_stderr
Dump in standard error.
void copy_members(const GLog &log)
Copy class members.
long int size(void) const
Return the number of characters in the log file.
GLog(void)
Void constructor.
void flush(const bool &force=false)
Flush string buffer into log file.
int m_indent
Indentation of text.
bool m_linestart
Signals that buffer is at line start.
GLog & operator=(const GLog &log)
Assignment operator.
void operator()(const char *msgFormat,...)
Message logging operator.
void open(const GFilename &filename, const bool &clobber=false)
Open log file.
std::string m_name
Name for prefix.
const GFilename & filename(void) const
Return log filename.
bool m_stdout
Dump in standard output.
bool m_use_date
Dump date in prefix.
const std::string & buffer(void) const
Return logger buffer.
GFilename m_filename
Log file name.
void header(const std::string &arg, int level)
Write string as header into logger.
void close(void)
Close log file.
FILE * m_file
Log file pointer.
long int m_written_size
Number of char's written though this logger.
void init_members(void)
Initialise class members.
GLog & operator<<(GLog &log)
Insert logger into logger.
void clear(void)
Clear object.
GChatter m_chatter
Chattiness for print() method.
std::string m_buffer
Output string buffer.
std::string prefix(void) const
Return prefix.
std::string strdate(void)
Return current date.
std::string fill(const std::string &s, const int &n)
Fill string with n strings of same type.