Skip to content

Conversation

Klaim
Copy link

@Klaim Klaim commented Nov 12, 2012

This PR adds

  • a logging library that act as a "router" of logging records to the log handler.
  • CMake options to force logging in non-debug or disable (remove) logging system.
  • a way for user code to set a custom logging handler.
  • a default logging handler that just push messages in std::cerr.

Initial discussion started here: https://groups.google.com/d/msg/cpp-netlib/KeR_uh7wl2A/tirSOCJsf_8J

Current discussion is going on there: https://groups.google.com/forum/?fromgroups=#!topic/cpp-netlib/Uv98-L44OwE

This is subject to discussion and improvements.
Note: the log_record object will certainly evolve in the future.

@glynos
Copy link
Member

glynos commented Nov 12, 2012

The files you have added are lacking the license info and copyright notice.

Furthermore, there are no unit tests for the stand-alone logger. You only modified an existing test but you should create a new one to test new code and to revert the original tests.

@Klaim
Copy link
Author

Klaim commented Nov 12, 2012

Ok I'll remove the test, add a proprer test and fix indentation and copyright.
Should I put my name in the copyright or not?

@ghost ghost assigned deanberris Nov 12, 2012
@deanberris
Copy link
Member

Yes, please put your name in the copyright.

class log_record
{
public:
log_record(){} // = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use =default now that we're C++11 only anyway.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I just cannot compile this at this time as I'm using VS2012 and don't have easy access to other compiler for some time. I'll do it anyway and try to compile it on my server.

@Klaim
Copy link
Author

Klaim commented Nov 13, 2012

Just an additional comment: I will do the improvements in the coming days, not today (I'm traveling for business). I think I'll be able to compile on another compiler before next week.

Klaim added 11 commits November 15, 2012 12:05
Some temporary files got into the last commit, removed them now.
- log record informations are now separated
- the log handler decide how to format the log record
- log record accepts more than compatible-to-string types on
construction,
anything string-streamable will work (need additional tests though)
@@ -11,16 +12,26 @@
print out network-related errors through standard error. This is only
useful when NETWORK_DEBUG is turned on. Otherwise the macro amounts to a
no-op.
The user can force the logging to be enabled by defining NETWORK_ENABLE_LOG.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can you move this down one line? 😀

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups I forgot to do this.

@deanberris
Copy link
Member

LGTM

Can you pull from master, merge locally (on your machine), then publish again to your master? I'll want to be able to merge this automatically.

Conflicts:
	libs/network/src/CMakeLists.txt
	libs/network/test/CMakeLists.txt
}

std::string message() const { return m_text_stream.str(); }
const std::string& filename() const { return m_filename; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to return a const ref, it can better return a value IMO.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure? Even if it's only to read the value? I know move semantics makes things cheaper but they keep saying it's still not free. I'll do it if you confirm you prefer by value, I have no problem with that. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think returning a value is necessary here. It's harmless to return a reference at this point.

deanberris added a commit that referenced this pull request Nov 16, 2012
Logging improvements: options & custom log record handling
@deanberris deanberris merged commit 815a529 into cpp-netlib:master Nov 16, 2012
@deanberris
Copy link
Member

Well done Joël, thanks for this PR!

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

Successfully merging this pull request may close these issues.

3 participants