Mercurial > hg > orthanc-webviewer
changeset 65:78aa0a355d3a
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Aug 2015 14:13:04 +0200 |
parents | 03a09c575ba8 |
children | a92e96943496 |
files | CMakeLists.txt Orthanc/Core/FileStorage/FilesystemStorage.cpp Orthanc/Core/ImageFormats/ImageAccessor.cpp Orthanc/Core/Logging.h Orthanc/Core/PrecompiledHeaders.h Orthanc/Core/SQLite/Connection.cpp Orthanc/Core/SQLite/Statement.cpp Orthanc/Core/SQLite/StatementReference.cpp Orthanc/Core/Toolbox.cpp Orthanc/Core/Toolbox.h Resources/SyncOrthancFolder.py |
diffstat | 11 files changed, 119 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Sun Aug 02 15:30:06 2015 +0200 +++ b/CMakeLists.txt Tue Aug 04 14:13:04 2015 +0200 @@ -132,6 +132,7 @@ add_definitions( -DORTHANC_ENABLE_MD5=0 -DORTHANC_ENABLE_BASE64=0 + -DORTHANC_ENABLE_LOGGING=0 ) set(CORE_SOURCES
--- a/Orthanc/Core/FileStorage/FilesystemStorage.cpp Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/FileStorage/FilesystemStorage.cpp Tue Aug 04 14:13:04 2015 +0200 @@ -36,15 +36,13 @@ // http://stackoverflow.com/questions/1576272/storing-large-number-of-files-in-file-system // http://stackoverflow.com/questions/446358/storing-a-large-number-of-images +#include "../Logging.h" #include "../OrthancException.h" #include "../Toolbox.h" #include "../Uuid.h" #include <boost/filesystem/fstream.hpp> -#if HAVE_GOOGLE_LOG == 1 -#include <glog/logging.h> -#endif static std::string ToString(const boost::filesystem::path& p) { @@ -215,7 +213,7 @@ void FilesystemStorage::Remove(const std::string& uuid, FileContentType /*type*/) { -#if HAVE_GOOGLE_LOG == 1 +#if ORTHANC_ENABLE_GOOGLE_LOG == 1 LOG(INFO) << "Deleting file " << uuid; #endif
--- a/Orthanc/Core/ImageFormats/ImageAccessor.cpp Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/ImageFormats/ImageAccessor.cpp Tue Aug 04 14:13:04 2015 +0200 @@ -33,6 +33,7 @@ #include "../PrecompiledHeaders.h" #include "ImageAccessor.h" +#include "../Logging.h" #include "../OrthancException.h" #include "../ChunkedBuffer.h" @@ -40,9 +41,6 @@ #include <cassert> #include <boost/lexical_cast.hpp> -#if HAVE_GOOGLE_LOG == 1 -#include <glog/logging.h> -#endif namespace Orthanc @@ -108,7 +106,7 @@ { if (readOnly_) { -#if HAVE_GOOGLE_LOG == 1 +#if ORTHANC_ENABLE_LOGGING == 1 LOG(ERROR) << "Trying to write on a read-only image"; #endif @@ -136,7 +134,7 @@ { if (readOnly_) { -#if HAVE_GOOGLE_LOG == 1 +#if ORTHANC_ENABLE_LOGGING == 1 LOG(ERROR) << "Trying to write on a read-only image"; #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orthanc/Core/Logging.h Tue Aug 04 14:13:04 2015 +0200 @@ -0,0 +1,93 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#if ORTHANC_ENABLE_LOGGING == 1 + +#if ORTHANC_ENABLE_GOOGLE_LOG == 1 +# include <stdlib.h> // This fixes a problem in glog for recent releases of MinGW +# include <glog/logging.h> +#else +# include <iostream> +# include <boost/thread/mutex.hpp> +# define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) +# define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) +#endif + + +namespace Orthanc +{ + namespace Logging + { + void Initialize(); + + void Finalize(); + + void EnableInfoLevel(bool enabled); + + void EnableTraceLevel(bool enabled); + + void SetTargetFolder(const std::string& path); + + +#if ORTHANC_ENABLE_GOOGLE_LOG != 1 + class InternalLogger + { + private: + boost::mutex::scoped_lock lock_; + std::ostream* stream_; + + public: + InternalLogger(const char* level, + const char* file, + int line); + + ~InternalLogger() + { +#if defined(_WIN32) + *stream_ << "\r\n"; +#else + *stream_ << "\n"; +#endif + } + + std::ostream& operator<< (const std::string& message) + { + return (*stream_) << message; + } + }; +#endif + } +} + +#endif // ORTHANC_ENABLE_LOGGING
--- a/Orthanc/Core/PrecompiledHeaders.h Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/PrecompiledHeaders.h Tue Aug 04 14:13:04 2015 +0200 @@ -46,7 +46,6 @@ #include <boost/thread.hpp> #include <boost/thread/shared_mutex.hpp> -#include <glog/logging.h> #include <json/value.h> #if ORTHANC_PUGIXML_ENABLED == 1 @@ -54,6 +53,7 @@ #endif #include "Enumerations.h" +#include "Logging.h" #include "OrthancException.h" #include "Toolbox.h" #include "Uuid.h"
--- a/Orthanc/Core/SQLite/Connection.cpp Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/SQLite/Connection.cpp Tue Aug 04 14:13:04 2015 +0200 @@ -47,7 +47,7 @@ #include <string.h> #if ORTHANC_SQLITE_STANDALONE != 1 -#include <glog/logging.h> +#include "../Logging.h" #endif #include "sqlite3.h"
--- a/Orthanc/Core/SQLite/Statement.cpp Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/SQLite/Statement.cpp Tue Aug 04 14:13:04 2015 +0200 @@ -47,7 +47,7 @@ #include <algorithm> #if ORTHANC_SQLITE_STANDALONE != 1 -#include <glog/logging.h> +#include "../Logging.h" #endif #include "sqlite3.h"
--- a/Orthanc/Core/SQLite/StatementReference.cpp Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/SQLite/StatementReference.cpp Tue Aug 04 14:13:04 2015 +0200 @@ -43,7 +43,7 @@ #include "OrthancSQLiteException.h" #if ORTHANC_SQLITE_STANDALONE != 1 -#include <glog/logging.h> +#include "../Logging.h" #endif #include <string>
--- a/Orthanc/Core/Toolbox.cpp Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/Toolbox.cpp Tue Aug 04 14:13:04 2015 +0200 @@ -34,6 +34,7 @@ #include "Toolbox.h" #include "OrthancException.h" +#include "Logging.h" #include <string> #include <stdint.h> @@ -53,13 +54,9 @@ #include <boost/regex.hpp> #endif -#if HAVE_GOOGLE_LOG == 1 -#include <glog/logging.h> -#endif - #if defined(_WIN32) #include <windows.h> -#include <process.h> // For "_spawnvp()" +#include <process.h> // For "_spawnvp()" and "_getpid()" #else #include <unistd.h> // For "execvp()" #include <sys/wait.h> // For "waitpid()" @@ -1135,7 +1132,7 @@ if (pid == -1) { // Error in fork() -#if HAVE_GOOGLE_LOG == 1 +#if ORTHANC_ENABLE_LOGGING == 1 LOG(ERROR) << "Cannot fork a child process"; #endif @@ -1158,7 +1155,7 @@ if (status != 0) { -#if HAVE_GOOGLE_LOG == 1 +#if ORTHANC_ENABLE_LOGGING == 1 LOG(ERROR) << "System command failed with status code " << status; #endif @@ -1274,5 +1271,14 @@ } } + + int Toolbox::GetProcessId() + { +#if defined(_WIN32) + return static_cast<int>(_getpid()); +#else + return static_cast<int>(getpid()); +#endif + } }
--- a/Orthanc/Core/Toolbox.h Sun Aug 02 15:30:06 2015 +0200 +++ b/Orthanc/Core/Toolbox.h Tue Aug 04 14:13:04 2015 +0200 @@ -170,5 +170,7 @@ bool StartsWith(const std::string& str, const std::string& prefix); + + int GetProcessId(); } }
--- a/Resources/SyncOrthancFolder.py Sun Aug 02 15:30:06 2015 +0200 +++ b/Resources/SyncOrthancFolder.py Tue Aug 04 14:13:04 2015 +0200 @@ -34,6 +34,7 @@ 'Core/ImageFormats/PngReader.h', 'Core/ImageFormats/PngWriter.cpp', 'Core/ImageFormats/PngWriter.h', + 'Core/Logging.h', 'Core/MultiThreading/SharedMessageQueue.cpp', 'Core/MultiThreading/SharedMessageQueue.h', 'Core/OrthancException.cpp',