Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #include <fstream> 7 : #include <sstream> 8 : #include <stdlib.h> 9 : #include <base/misc_utils.h> 10 : #include <base/logging.h> 11 : #include <netdb.h> 12 : #include <netinet/in.h> 13 : #include <arpa/inet.h> 14 : #include "base/sandesh/version_types.h" 15 : #include "base/logging.h" 16 : #include "rapidjson/document.h" 17 : #include "rapidjson/writer.h" 18 : #include "rapidjson/stringbuffer.h" 19 : 20 : using namespace std; 21 : 22 : const map<MiscUtils::BuildModule, string> MiscUtils::BuildModuleNames = 23 : MiscUtils::MapInit(); 24 : time_t MiscUtils::startup_time_secs_ = MiscUtils::set_startup_time_secs(); 25 : 26 : SandeshTraceBufferPtr VersionTraceBuf(SandeshTraceBufferCreate( 27 : VERSION_TRACE_BUF, 500)); 28 : 29 0 : string MiscUtils::BaseName(string filename) { 30 0 : size_t pos = filename.find_last_of('/'); 31 0 : if (pos != string::npos) { 32 0 : return filename.substr((pos+1)); 33 : } 34 0 : return filename; 35 : } 36 : 37 0 : void MiscUtils::LogVersionInfo(const string build_info, Category::type categ) { 38 0 : VERSION_TRACE(VersionInfoTrace, build_info); 39 0 : if (!LoggingDisabled()) { 40 0 : VERSION_LOG(VersionInfoLog, categ, build_info); 41 : } 42 0 : } 43 : 44 9846 : time_t MiscUtils::GetUpTimeSeconds() { 45 9846 : return (UTCTimestamp() - startup_time_secs_); 46 : } 47 : 48 984 : time_t MiscUtils::set_startup_time_secs() { 49 984 : return (startup_time_secs_ = UTCTimestamp()); 50 : }