Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable default log #590

Open
saurabhmnnit09 opened this issue Nov 8, 2017 · 9 comments
Open

How to disable default log #590

saurabhmnnit09 opened this issue Nov 8, 2017 · 9 comments

Comments

@saurabhmnnit09
Copy link

See , I am using configfromglobal function and I don't want myeasylog.log file to be created. I tried disabling the macro for default log but still myeasylog.log is being made

@chrisniael
Copy link

chrisniael commented Nov 15, 2017

Define the macro ELPP_NO_DEFAULT_LOG_FILE using -D option of compiler, for example in case of g++ you need do g++ source.cpp ... -DELPP_NO_DEFAULT_LOG_FILE .... And if you are using cmake system, you should define the macro in the CMakeLists.txt, set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DELPP_NO_DEFAULT_LOG_FILE")

@rdiachenko
Copy link

@chrisniael , how should I define this macro in Visual Studio?
This doesn't work:

#define ELPP_NO_DEFAULT_LOG_FILE
#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP

@chrisniael
Copy link

@rdiachenko

To set this compiler option in the Visual Studio development environment

  1. Open the project Property Pages dialog box. For more information, see How to: Open Project Property Pages.
  2. In the left pane, select Configuration Properties, C/C++, Preprocessor.
  3. In the right pane, in the right-hand column of the Preprocessor Definitions property, open the drop-down menu and choose Edit.
  4. In the Preprocessor Definitions dialog box, add (one per line), modify, or delete one or more definitions. Choose OK to save your changes.

Refer to Microsoft's reference document /D (Preprocessor Definitions)

@rdiachenko
Copy link

@chrisniael , thanks, it works specifying ELPP_NO_DEFAULT_LOG_FILE in the aforementioned way.
Any ideas why #define ELPP_NO_DEFAULT_LOG_FILE doesn't work?

@chrisniael
Copy link

chrisniael commented Nov 24, 2017

@rdiachenko I assume your code file name is main.cpp, where define the macro ELPP_NO_DEFAULT_LOG_FILE, as your said above:

//main.cpp
#define ELPP_NO_DEFAULT_LOG_FILE
#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP

when the compiler build your project, it has many steps. one of these steps is to compile easylogging++.cpp and main.cpp to their object files separately (easylogging++.o and main.o), when compiling easylogging++.cpp, the compiler don't find the macro define ELPP_NO_DEFAULT_LOG_FILE in its dependent files(easylogging++.h), because the macro define ELPP_NO_DEFAULT_LOG_FILE is only in the main.cpp.

@rdiachenko
Copy link

@chrisniael thanks for explanation, it makes things clear for now. Looks like it does make sense to add your note to README

@chrisniael
Copy link

@rdiachenko You're welcome : )

@mage-game
Copy link

@chrisniael Thanks for your explanation

@rdiachenko
Copy link

I suppose this issue can be closed. The pull request with clarifications for macros configuration was applied - #597

username223 added a commit to OpenVR-Advanced-Settings/OpenVR-AdvancedSettings that referenced this issue Dec 28, 2018
Defines done outside of easylogging++.h does not work according to
official documentation
(https://github.com/zuhd-org/easyloggingpp/blob/master/README.md#configuration-macros)

"NOTE: All the macros can be defined in one of the following ways:

1. Define macros using -D option of compiler, for example in case of
g++ you will do g++ source.cpp ... -DELPP_SYSLOG -DELPP_THREAD_SAFE
... (recommended way)

2. Define macros inside "easylogging++.h" (defining macros in other
files won't work)"

Linking to this issue:
abumq/easyloggingpp#590 (comment)

We are using the developer recommended way of defining them by command
line.

What is assumed to be the intention of enabling debug logs before
including easylogging++ never actually did anything, hence this define
is dropped. Newer versions of easylogging++ uses the macro
ELPP_DISABLE_DEBUG_LOGS to _disable_ debug logs. Leaving that macro
undefined satisfies the original intent.
ykeara added a commit to ykeara/OpenVR-AdvancedSettings that referenced this issue Jan 3, 2019
Update logging dependency from 9.84 to 9.89

This is the newest version that doesn't lead to compile errors. It has
also reduced the amount of "-Wexpansion-to-defined" errors on clang-msvc
by about 80 (from ~400 to 320).

Update easylogging license file

Originally came as LICENCE.txt (notice C instead of S in LICENSE),
renamed to better fit into the git history.

Move logging defines to QMAKE instead of logging.h

Defines done outside of easylogging++.h does not work according to
official documentation
(https://github.com/zuhd-org/easyloggingpp/blob/master/README.md#configuration-macros)

"NOTE: All the macros can be defined in one of the following ways:

1. Define macros using -D option of compiler, for example in case of
g++ you will do g++ source.cpp ... -DELPP_SYSLOG -DELPP_THREAD_SAFE
... (recommended way)

2. Define macros inside "easylogging++.h" (defining macros in other
files won't work)"

Linking to this issue:
abumq/easyloggingpp#590 (comment)

We are using the developer recommended way of defining them by command
line.

What is assumed to be the intention of enabling debug logs before
including easylogging++ never actually did anything, hence this define
is dropped. Newer versions of easylogging++ uses the macro
ELPP_DISABLE_DEBUG_LOGS to _disable_ debug logs. Leaving that macro
undefined satisfies the original intent.

Move easylogging++ include into necessary files

logging.h previously had logic to enable debug logging even on release
builds. This logic was moved to the QMAKE file, hence the logging.h file
is no longer necessary.

Update easylogging++ to 9.96.7, turn on /WX for clang-msvc

Updating from easylogging++ 9.89 to 9.96.7 turns it from a header only
library to one requiring a source file. It has been added to sources
near the other third party includes in the QMAKE to signify that it
isn't a first party file.

Updating easylogging++ also means that clang-msvc can compile without
any warnings, hence turning on warnings as errors for that compiler as
well, to avoid any regressions.

updated to current

fixed formatting

fixed ptt add bug/compilerwarnings/c++14 target

cleaned up .pro file

fixed casting back to c++ style

added default profile and ptt profile view
ykeara added a commit to ykeara/OpenVR-AdvancedSettings that referenced this issue Jan 3, 2019
Update logging dependency from 9.84 to 9.89

This is the newest version that doesn't lead to compile errors. It has
also reduced the amount of "-Wexpansion-to-defined" errors on clang-msvc
by about 80 (from ~400 to 320).

Update easylogging license file

Originally came as LICENCE.txt (notice C instead of S in LICENSE),
renamed to better fit into the git history.

Move logging defines to QMAKE instead of logging.h

Defines done outside of easylogging++.h does not work according to
official documentation
(https://github.com/zuhd-org/easyloggingpp/blob/master/README.md#configuration-macros)

"NOTE: All the macros can be defined in one of the following ways:

1. Define macros using -D option of compiler, for example in case of
g++ you will do g++ source.cpp ... -DELPP_SYSLOG -DELPP_THREAD_SAFE
... (recommended way)

2. Define macros inside "easylogging++.h" (defining macros in other
files won't work)"

Linking to this issue:
abumq/easyloggingpp#590 (comment)

We are using the developer recommended way of defining them by command
line.

What is assumed to be the intention of enabling debug logs before
including easylogging++ never actually did anything, hence this define
is dropped. Newer versions of easylogging++ uses the macro
ELPP_DISABLE_DEBUG_LOGS to _disable_ debug logs. Leaving that macro
undefined satisfies the original intent.

Move easylogging++ include into necessary files

logging.h previously had logic to enable debug logging even on release
builds. This logic was moved to the QMAKE file, hence the logging.h file
is no longer necessary.

Update easylogging++ to 9.96.7, turn on /WX for clang-msvc

Updating from easylogging++ 9.89 to 9.96.7 turns it from a header only
library to one requiring a source file. It has been added to sources
near the other third party includes in the QMAKE to signify that it
isn't a first party file.

Updating easylogging++ also means that clang-msvc can compile without
any warnings, hence turning on warnings as errors for that compiler as
well, to avoid any regressions.

updated to current

fixed formatting

fixed ptt add bug/compilerwarnings/c++14 target

cleaned up .pro file

fixed casting back to c++ style

added default profile and ptt profile view
ykeara added a commit to ykeara/OpenVR-AdvancedSettings that referenced this issue Jan 3, 2019
Update logging dependency from 9.84 to 9.89

This is the newest version that doesn't lead to compile errors. It has
also reduced the amount of "-Wexpansion-to-defined" errors on clang-msvc
by about 80 (from ~400 to 320).

Update easylogging license file

Originally came as LICENCE.txt (notice C instead of S in LICENSE),
renamed to better fit into the git history.

Move logging defines to QMAKE instead of logging.h

Defines done outside of easylogging++.h does not work according to
official documentation
(https://github.com/zuhd-org/easyloggingpp/blob/master/README.md#configuration-macros)

"NOTE: All the macros can be defined in one of the following ways:

1. Define macros using -D option of compiler, for example in case of
g++ you will do g++ source.cpp ... -DELPP_SYSLOG -DELPP_THREAD_SAFE
... (recommended way)

2. Define macros inside "easylogging++.h" (defining macros in other
files won't work)"

Linking to this issue:
abumq/easyloggingpp#590 (comment)

We are using the developer recommended way of defining them by command
line.

What is assumed to be the intention of enabling debug logs before
including easylogging++ never actually did anything, hence this define
is dropped. Newer versions of easylogging++ uses the macro
ELPP_DISABLE_DEBUG_LOGS to _disable_ debug logs. Leaving that macro
undefined satisfies the original intent.

Move easylogging++ include into necessary files

logging.h previously had logic to enable debug logging even on release
builds. This logic was moved to the QMAKE file, hence the logging.h file
is no longer necessary.

Update easylogging++ to 9.96.7, turn on /WX for clang-msvc

Updating from easylogging++ 9.89 to 9.96.7 turns it from a header only
library to one requiring a source file. It has been added to sources
near the other third party includes in the QMAKE to signify that it
isn't a first party file.

Updating easylogging++ also means that clang-msvc can compile without
any warnings, hence turning on warnings as errors for that compiler as
well, to avoid any regressions.

updated to current

fixed formatting

fixed ptt add bug/compilerwarnings/c++14 target

cleaned up .pro file

fixed casting back to c++ style

added default profile and ptt profile view

fixed c++ casts

fixed logic error on getDevice functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants