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