commit 59d74aea1f11cd1fb0df3e1dea97f731bfd21dd0 Author: Valient Gough Date: Sat Aug 5 23:23:41 2017 -0700 Squashed 'vendor/github.com/muflihun/easyloggingpp/' content from commit 850ea2a9 git-subtree-dir: vendor/github.com/muflihun/easyloggingpp git-subtree-split: 850ea2a9f151ed648a989dda1cf44e503e45831f diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..925782b --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +build/* +build-* +*.pro.user +.DS_Store +release.info +bin/* +logs/* +experiments/* +CMakeLists.txt.user diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..33569cf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +language: cpp +compiler: + - gcc +os: linux +dist: trusty +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y libgtest-dev valgrind + - sudo wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz + - sudo tar xf release-1.7.0.tar.gz + - cd googletest-release-1.7.0 + - sudo cmake -DBUILD_SHARED_LIBS=ON . + - sudo make + - sudo cp -a include/gtest /usr/include + - sudo cp -a libgtest_main.so libgtest.so /usr/lib/ + - which valgrind + - cd "${TRAVIS_BUILD_DIR}" +before_script: + - cd test/ + - cmake -Dtest=ON ../ + - make + - ls -l +script: "./easyloggingpp-unit-tests -v && cd ../samples/STL && pwd && sh ./.travis_build.sh && valgrind ./bin/very-basic.cpp.bin" +branches: + only: + - master + - develop +notifications: + recipients: + - mkhan3189@gmail.com + email: + on_success: never + on_failure: change +rvm: + - 9.00 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ca09e2d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,45 @@ +# Change Log + +## [9.95.0] - 02-08-2017 +### Added + - Added NetBSD as unix [coypoop](https://github.com/muflihun/easyloggingpp/pull/548/commits) + - Ignore `NDEBUG` or `_DEBUG` to determine whether debug logs should be enabled or not. Use `ELPP_DISABLE_DEBUG_LOGS` + +### Fixes + - Fix compile when `_USE_32_BIT_TIME_T` defined [gggin](https://github.com/muflihun/easyloggingpp/pull/542/files) + - Fix invalid usage of safeDelete which can cause an error with valgrind [Touyote](https://github.com/muflihun/easyloggingpp/pull/544/files) + - Add code to ensure no nullptr references [tepperly](https://github.com/muflihun/easyloggingpp/pull/512/files) + +## [9.94.2] - 12-04-2017 +### Added + - CMake option to create static lib (thanks to @romariorios) + - Ability to use UTC time using `ELPP_UTC_DATETIME` (thanks to @romariorios) + - CMake module updated to support static lib + +### Changes + - Renamed long format specifiers to full names with padding for readbility + +### Fixes + - Fixed Android NDK build (thanks to @MoroccanMalinois) + - Fix `ELPP_DISABLE_LOGS` not working in VS (thanks to @goloap) #365 + +## [9.94.1] - 25-02-2017 +### Fixed + - Fixes for `/W4` level warnings generated in MSVC compile (Thanks to [Falconne](https://github.com/Falconne)) + - Fixed links + - Fixes removing default logger if other than `default` + +### Changes + - Changed documentation to mention `easylogging++.cc` in introduction and added links to features + +## [9.94.0] - 14-02-2017 +### Fixed + - Fixed performance tracking time unit and calculations + +### Added + - Restored `ELPP_DEFAULT_LOGGER` and `ELPP_DEFAULT_PERFORMANCE_LOGGER` + - `Helpers::getThreadName` for reading current thread name + - Custom format specifier now has to return `std::string` instead + - Merged `thread_name` with `thread` if thread name is available it's used otherwise ID is displayed + +For older versions please refer to [https://github.com/muflihun/easyloggingpp/tree/master/doc](https://github.com/muflihun/easyloggingpp/tree/master/doc) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1f7244b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,87 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(Easyloggingpp CXX) + +macro(require_cpp11) + if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0) + # CMake 3.1 has built-in CXX standard checks. + message("-- Setting C++11") + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED on) + else() + if (CMAKE_CXX_COMPILER_ID MATCHES "GCC") + message ("-- GNU CXX (-std=c++11)") + list(APPEND CMAKE_CXX_FLAGS "-std=c++11") + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + message ("-- CLang CXX (-std=c++11)") + list(APPEND CMAKE_CXX_FLAGS "-std=c++11") + else() + message ("-- Easylogging++ requires C++11. Your compiler does not support it.") + endif() + endif() +endmacro() + +option(test "Build all tests" OFF) +option(build_static_lib "Build easyloggingpp as a static library" OFF) +option(lib_utc_datetime "Build library with UTC date/time logging" OFF) + +set(ELPP_MAJOR_VERSION "9") +set(ELPP_MINOR_VERSION "95") +set(ELPP_PATCH_VERSION "0") +set(ELPP_VERSION_STRING "${ELPP_MAJOR_VERSION}.${ELPP_MINOR_VERSION}.${ELPP_PATCH_VERSION}") + +set(ELPP_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) + +install(FILES + src/easylogging++.h + src/easylogging++.cc + DESTINATION "${ELPP_INCLUDE_INSTALL_DIR}" + COMPONENT dev) + +if (build_static_lib) + if (lib_utc_datetime) + add_definitions(-DELPP_UTC_DATETIME) + endif() + + require_cpp11() + add_library(easyloggingpp STATIC src/easylogging++.cc) + + install(TARGETS + easyloggingpp + ARCHIVE DESTINATION lib) +endif() + +export(PACKAGE ${PROJECT_NAME}) + + +########################################## Unit Testing ################################### +if (test) + # We need C++11 + require_cpp11() + set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") + + find_package (gtest REQUIRED) + + include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) + + enable_testing() + + add_executable(easyloggingpp-unit-tests + src/easylogging++.cc + test/main.cc + ) + + target_compile_definitions(easyloggingpp-unit-tests PUBLIC + ELPP_FEATURE_ALL + ELPP_LOGGING_FLAGS_FROM_ARG + ELPP_NO_DEFAULT_LOG_FILE + ELPP_FRESH_LOG_FILE + ) + + # Standard linking to gtest stuff. + target_link_libraries(easyloggingpp-unit-tests gtest gtest_main) + + add_test(NAME easyloggingppUnitTests COMMAND easyloggingpp-unit-tests -v) +endif() diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..2c8998d --- /dev/null +++ b/LICENCE @@ -0,0 +1,24 @@ +The MIT License (MIT) + +Copyright (c) 2017 muflihun.com + +https://github.com/muflihun/ +https://muflihun.github.io +https://muflihun.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d0d2774 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +### This is a + +- [ ] Breaking change +- [ ] New feature +- [ ] Bugfix + +### I have + +- [ ] Merged in the latest upstream changes +- [ ] Updated [`CHANGELOG.md`](CHANGELOG.md) +- [ ] Updated [`README.md`](README.md) +- [ ] [Run the tests](README.md#install-optional) diff --git a/README.md b/README.md new file mode 100644 index 0000000..abc6899 --- /dev/null +++ b/README.md @@ -0,0 +1,1435 @@ + ‫بسم الله الرَّحْمَنِ الرَّحِيمِ + + +![banner] + +> **Manual For v9.95.0** + +[![Build Status (Develop)](https://img.shields.io/travis/muflihun/easyloggingpp/develop.svg)](https://travis-ci.org/muflihun/easyloggingpp) (`develop`) + +[![Build Status (Master)](https://img.shields.io/travis/muflihun/easyloggingpp/master.svg)](https://travis-ci.org/muflihun/easyloggingpp) (`master`) + +[![Version](https://img.shields.io/github/release/muflihun/easyloggingpp.svg)](https://github.com/muflihun/easyloggingpp/releases/latest) + +[![Canon.io](https://img.shields.io/badge/conan.io-easyloggingpp%2F9.95.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC)](http://www.conan.io/source/easyloggingpp/9.95.0/memsharded/testing) + +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](http://melpon.org/wandbox/permlink/rwDXGcnP1IoCKXrJ) + +[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/muflihun/easyloggingpp/blob/master/LICENCE) + +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/MuflihunDotCom/25) + +[![Downloads](https://img.shields.io/github/downloads/muflihun/easyloggingpp/total.svg)](https://github.com/muflihun/easyloggingpp/releases/latest) + +### Quick Links + + [![download] Latest Release](https://github.com/muflihun/easyloggingpp/releases/latest) + + [![notes] Changelog](/CHANGELOG.md) + + [![samples] Samples](/samples) + +--- + +### Table of Contents +
+Introduction
+    Why yet another library
+    Features at a glance
+Getting Started
+    Download
+    Quick Start
+    Install (Optional)
+    Setting Application Arguments
+Configuration
+    Level
+    Configure
+        Using Configuration File
+        Using el::Configurations Class
+        Using In line Configurations
+    Default Configurations
+    Global Configurations
+    Logging Format Specifiers
+    Date/Time Format Specifiers
+    Custom Format Specifiers
+    Logging Flags
+    Application Arguments
+    Configuration Macros
+    Reading Configurations
+Logging
+    Basic
+    Conditional Logging
+    Occasional Logging
+    printf Like Logging
+    Network Logging
+    Verbose Logging
+        Basic
+        Conditional and Occasional
+        Verbose Level
+        Check If Verbose Logging Is On
+        VModule
+    Registering New Loggers
+    Unregister Loggers
+    Populating Existing Logger IDs
+    Sharing Logging Repository
+Extra Features
+    Performance Tracking
+        Conditional Performance Tracking
+        Make Use of Performance Tracking Data
+    Log File Rotating
+    Crash Handling
+        Installing Custom Crash Handlers
+    Stacktrace
+    Multi-threading
+    CHECK Macros
+    Logging perror()
+    Using Syslog
+    STL Logging
+        Supported Templates
+    Qt Logging
+    Boost Logging
+    wxWidgets Logging
+    Extending Library
+        Logging Your Own Class
+        Logging Third-party Class
+    Manually Flushing and Rolling Log Files
+    Log Dispatch Callback
+    Logger Registration Callback
+    Asynchronous Logging
+    Helper Classes
+Contribution
+    Submitting Patches
+    Reporting a Bug
+Compatibility
+Licence
+Disclaimer
+
+ +# Introduction +Easylogging++ is single header efficient logging library for C++ applications. It is extremely powerful, highly extendable and configurable to user's requirements. It provides ability to [write your own sinks](https://github.com/muflihun/easyloggingpp/tree/master/samples/send-to-network) (referred to as `LogDispatchCallback`). Currently used by hundreds of open-source projects. + +This manual is for Easylogging++ v9.95.0. For other versions please refer to corresponding [release](https://github.com/muflihun/easyloggingpp/releases) on github. + + [![top] Goto Top](#table-of-contents) + +### Why yet another library +If you are working on a small utility or large project in C++, this library can be handy. Its based on single header and only requires to link to single source file. (Originally it was header-only and was changed to use source file in [issue #445](https://github.com/muflihun/easyloggingpp/issues/445). You can still use header-only in [v9.89](https://github.com/muflihun/easyloggingpp/releases/tag/9.89)). + +This library has been designed with various thoughts in mind (i.e, portability, performance, usability, features and easy to setup). + +Why yet another library? Well, answer is pretty straight forward, use it as you wrote it so you can fix issues (if any) as you go or raise them on github. In addition to that, I personally have not seen any logging library based on single-header with such a design where you can configure on the go, extend it to your needs and get fast performance. I have seen other single-header logging libraries for C++ but either they use external libraries, e.g, boost or Qt to support certain features like threading, regular expression or date etc. This library has everything built-in to prevent usage of external libraries, not that I don't like those libraries, in fact I love them, but because not all projects use these libraries, I couldn't take risk of depending on them. + + [![top] Goto Top](#table-of-contents) + +### Features at a glance +Easylogging++ is feature-rich containing many features that both typical and advanced developer will require while writing a software; + * [Highly configurable](#configuration) + * [Extendable](#log-dispatch-callback) + * Extremely fast + * [Thread](#multi-threading) and type safe + * [Cross-platform](#compatibility) + * [Custom log patterns](#logging-format-specifiers) + * [Conditional and occasional logging](#conditional-logging) + * [Performance tracking](#performance-tracking) + * [Verbose logging](#verbose-logging) + * [Crash handling](#crash-handling) + * [Helper CHECK macros](#check-macros) + * [STL logging](#stl-logging) + * [Send to Syslog](#syslog) + * [Third-party library logging (Qt, boost, wxWidgets etc)](#logging-third-party-class) + * [Extensible (Logging your own class or third-party class)](#logging-your-own-class) + * [And many more...](#extra-features) + + [![top] Goto Top](#table-of-contents) + +# Getting Started +### Download +Download latest version from [Latest Release](https://github.com/muflihun/easyloggingpp/releases/latest) + +For other releases, please visit [releases page](https://github.com/muflihun/easyloggingpp/releases). If you application does not support C++11, please consider using [v8.91](https://github.com/muflihun/easyloggingpp/tree/v8.91). This is stable version for C++98 and C++03, just lack some features. + + [![top] Goto Top](#table-of-contents) + +### Quick Start +In order to get started with Easylogging++, you can follow three easy steps: +* Download latest version +* Include into your project (`easylogging++.h` and `easylogging++.cc`) +* Initialize using single macro... and off you go! + +```c++ +#include "easylogging++.h" + +INITIALIZE_EASYLOGGINGPP + +int main(int argc, char* argv[]) { + LOG(INFO) << "My first info log using default logger"; + return 0; +} +``` + +Now compile using + +``` +g++ main.cc easylogging++.cc -o prog -std=c++11 +``` + +That simple! Please note that `INITIALIZE_EASYLOGGINGPP` should be used once and once-only otherwise you will end up getting compilation errors. This is definiting several `extern` variables. This means it can be defined only once per application. Best place to put this initialization statement is in file where `int main(int, char**)` function is defined, right after last include statement. + +### Install (Optional) +If you want to install this header system-wide, you can do so via: +``` +mkdir build +cd build +cmake -Dtest=ON ../ +make +make test +make install +``` + +Following options are supported by Easylogging++ cmake and you can turn these options on using `-D