Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Which of the two options will better suit the program flow ?

Depends. Neither is fit for all situations, or optimal.

Are there any better alternatives than these two ?

Yes. Normally, logging is a module/part of the functionality of an application, orthogonal to the rest of the functionality (that is, you should be able to alter the app logic without changing the logging code implementation, and alter logging code without altering application logic).

Because of this, logging is usually implemented as a separate library, and should support:

  • multiple sinks (write message to multiple logs at the same time)
  • message metadata (module name, thread id, time, message type, etc)
  • prioritized dispatching of messages (a warning could/should be processed differently than the error)
  • configuration at runtime

As alternatives, have a look at some c++ logging frameworks (result of google search) and this question this question.

Which of the two options will better suit the program flow ?

Depends. Neither is fit for all situations, or optimal.

Are there any better alternatives than these two ?

Yes. Normally, logging is a module/part of the functionality of an application, orthogonal to the rest of the functionality (that is, you should be able to alter the app logic without changing the logging code implementation, and alter logging code without altering application logic).

Because of this, logging is usually implemented as a separate library, and should support:

  • multiple sinks (write message to multiple logs at the same time)
  • message metadata (module name, thread id, time, message type, etc)
  • prioritized dispatching of messages (a warning could/should be processed differently than the error)
  • configuration at runtime

As alternatives, have a look at some c++ logging frameworks (result of google search) and this question.

Which of the two options will better suit the program flow ?

Depends. Neither is fit for all situations, or optimal.

Are there any better alternatives than these two ?

Yes. Normally, logging is a module/part of the functionality of an application, orthogonal to the rest of the functionality (that is, you should be able to alter the app logic without changing the logging code implementation, and alter logging code without altering application logic).

Because of this, logging is usually implemented as a separate library, and should support:

  • multiple sinks (write message to multiple logs at the same time)
  • message metadata (module name, thread id, time, message type, etc)
  • prioritized dispatching of messages (a warning could/should be processed differently than the error)
  • configuration at runtime

As alternatives, have a look at some c++ logging frameworks (result of google search) and this question.

Source Link
utnapistim
  • 3.6k
  • 15
  • 21

Which of the two options will better suit the program flow ?

Depends. Neither is fit for all situations, or optimal.

Are there any better alternatives than these two ?

Yes. Normally, logging is a module/part of the functionality of an application, orthogonal to the rest of the functionality (that is, you should be able to alter the app logic without changing the logging code implementation, and alter logging code without altering application logic).

Because of this, logging is usually implemented as a separate library, and should support:

  • multiple sinks (write message to multiple logs at the same time)
  • message metadata (module name, thread id, time, message type, etc)
  • prioritized dispatching of messages (a warning could/should be processed differently than the error)
  • configuration at runtime

As alternatives, have a look at some c++ logging frameworks (result of google search) and this question.

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /