Removed comment header, timestamp shows microsecs

This commit is contained in:
Bob Polis 2023-08-03 10:58:03 +02:00
parent 2671859cc9
commit 870a90c6a7
2 changed files with 1 additions and 18 deletions

View File

@ -1,11 +1,3 @@
//
// logger.cpp
// libsclogging
//
// Created by Bob Polis at 2020-04-29
// Copyright (c) 2020 SwiftCoder. All rights reserved.
//
#include "logger.hpp" #include "logger.hpp"
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
@ -33,13 +25,12 @@ void logger::write_prefix(loglevel level, const char* file, int line, const char
// retrieve accurate time for milliseconds display // retrieve accurate time for milliseconds display
struct timeval secs; struct timeval secs;
(void)::gettimeofday(&secs, nullptr); (void)::gettimeofday(&secs, nullptr);
int ms = static_cast<int>(std::roundf(secs.tv_usec / 1000.0)) % 1000;
// create a date/time stamp // create a date/time stamp
char dtstamp[20]; char dtstamp[20];
std::strftime(dtstamp, 20, "%F %T", std::localtime(&secs.tv_sec)); std::strftime(dtstamp, 20, "%F %T", std::localtime(&secs.tv_sec));
std::cerr << dtstamp << "." << std::setfill('0') << std::setw(3) << ms << " "; std::cerr << dtstamp << "." << std::setfill('0') << std::setw(6) << secs.tv_usec << " ";
std::cerr << _name << "[" << ::getpid() << "] "; std::cerr << _name << "[" << ::getpid() << "] ";
std::cerr << file << ":" << line << " " << func << "() "; std::cerr << file << ":" << line << " " << func << "() ";
std::cerr << '[' << loglevel_desc(level) << "] "; std::cerr << '[' << loglevel_desc(level) << "] ";

View File

@ -1,11 +1,3 @@
//
// logger.hpp
// libsclogging
//
// Created by Bob Polis at 2020-04-29
// Copyright (c) 2020 SwiftCoder. All rights reserved.
//
#ifndef _logger_H_ #ifndef _logger_H_
#define _logger_H_ #define _logger_H_