sde: Add support for conditional logging.

1. Add support for conditional logging.
2. Move log handling to hwc client.

Change-Id: I76bb2f9b420a178f22c4ee2ebf64da6daf5b87ed
diff --git a/displayengine/include/core/core_interface.h b/displayengine/include/core/core_interface.h
old mode 100644
new mode 100755
index 45d9c8c..2229d1e
--- a/displayengine/include/core/core_interface.h
+++ b/displayengine/include/core/core_interface.h
@@ -35,20 +35,20 @@
 #include <stdint.h>
 
 #include "display_interface.h"
-#include "display_types.h"
+#include "sde_types.h"
 
-/*! @brief Display core interface version.
+/*! @brief Display engine interface version.
 
-  @details Display core interfaces are version tagged to maintain backward compatibility. This
+  @details Display engine interfaces are version tagged to maintain backward compatibility. This
   version is supplied as a default argument during display core initialization.
 
-  Client may use an older version of interfaces and link to a higher version of display core
+  Client may use an older version of interfaces and link to a higher version of display engine
   library, but vice versa is not allowed.
 
   A 32-bit client must use 32-bit display core library and a 64-bit client must use 64-bit display
   core library.
 
-  Display core interfaces follow default data structures alignment. Client must not override the
+  Display engine interfaces follow default data structures alignment. Client must not override the
   default padding rules while using these interfaces.
 
   @warning It is assumed that client upgrades or downgrades display core interface all at once
@@ -57,11 +57,11 @@
 
   @sa CoreInterface::CreateCore
 */
-#define CORE_REVISION_MAJOR (1)
-#define CORE_REVISION_MINOR (0)
+#define SDE_REVISION_MAJOR (1)
+#define SDE_REVISION_MINOR (0)
 
-#define CORE_VERSION_TAG ((uint32_t) ((CORE_REVISION_MAJOR << 24) | (CORE_REVISION_MINOR << 16) \
-                    | (sizeof(DisplayCompatibility) << 8) | sizeof(int *)))
+#define SDE_VERSION_TAG ((uint32_t) ((SDE_REVISION_MAJOR << 24) | (SDE_REVISION_MINOR << 16) | \
+                                    (sizeof(SDECompatibility) << 8) | sizeof(int *)))
 
 namespace sde {
 
@@ -120,15 +120,16 @@
     This interface shall be called only once.
 
     @param[in] event_handler \link CoreEventHandler \endlink
+    @param[in] log_handler \link LogHandler \endlink
     @param[out] interface \link CoreInterface \endlink
-    @param[in] version \link CORE_VERSION_TAG \endlink. Client must not override this argument.
+    @param[in] version \link SDE_VERSION_TAG \endlink. Client must not override this argument.
 
     @return \link DisplayError \endlink
 
     @sa DestroyCore
   */
-  static DisplayError CreateCore(CoreEventHandler *event_handler, CoreInterface **interface,
-                                 uint32_t version = CORE_VERSION_TAG);
+  static DisplayError CreateCore(CoreEventHandler *event_handler, LogHandler *log_handler,
+                                 CoreInterface **interface, uint32_t version = SDE_VERSION_TAG);
 
   /*! @brief Method to release handle to display core interface.
 
@@ -159,7 +160,7 @@
     @sa DestroyDisplay
   */
   virtual DisplayError CreateDisplay(DisplayType type, DisplayEventHandler *event_handler,
-                                    DisplayInterface **interface) = 0;
+                                     DisplayInterface **interface) = 0;
 
   /*! @brief Method to destroy a display device.
 
diff --git a/displayengine/include/core/display_interface.h b/displayengine/include/core/display_interface.h
old mode 100644
new mode 100755
index bb03921..dfe161b
--- a/displayengine/include/core/display_interface.h
+++ b/displayengine/include/core/display_interface.h
@@ -36,7 +36,7 @@
 #include <stdint.h>
 
 #include "layer_stack.h"
-#include "display_types.h"
+#include "sde_types.h"
 
 namespace sde {
 
diff --git a/displayengine/include/core/display_types.h b/displayengine/include/core/display_types.h
deleted file mode 100644
index 128e7d9..0000000
--- a/displayengine/include/core/display_types.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Copyright (c) 2014, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without modification, are permitted
-* provided that the following conditions are met:
-*    * Redistributions of source code must retain the above copyright notice, this list of
-*      conditions and the following disclaimer.
-*    * Redistributions in binary form must reproduce the above copyright notice, this list of
-*      conditions and the following disclaimer in the documentation and/or other materials provided
-*      with the distribution.
-*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
-*      endorse or promote products derived from this software without specific prior written
-*      permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*! @file display_types.h
-  @brief This file contains miscellaneous data types used across display interfaces.
-*/
-#ifndef __DISPLAY_TYPES_H__
-#define __DISPLAY_TYPES_H__
-
-namespace sde {
-
-/*! @brief This enum represents different error codes that display interfaces may return.
-*/
-enum DisplayError {
-  kErrorNone = 0,         //!< Call executed successfully.
-  kErrorUndefined,        //!< An unspecified error has occured.
-  kErrorNotSupported,     //!< Requested operation is not supported.
-  kErrorVersion,          //!< Client is using advanced version of interfaces and calling into an
-                          //!< older version of display library.
-  kErrorDataAlignment,    //!< Client data structures are not aligned on naturual boundaries.
-  kErrorInstructionSet,   //!< 32-bit client is calling into 64-bit library or vice versa.
-  kErrorParameters,       //!< Invalid parameters passed to a method.
-  kErrorFileDescriptor,   //!< Invalid file descriptor.
-  kErrorMemory,           //!< System is running low on memory.
-  kErrorResources,        //!< Not enough hardware resources available to execute call.
-  kErrorHardware,         //!< A hardware error has occured.
-  kErrorTimeOut,          //!< The operation has timed out to prevent client from waiting forever.
-};
-
-/*! @brief This structure is defined for client and library compatibility check purpose only. This
-  structure is used in CORE_VERSION_TAG definition only. Client should not refer it directly for
-  any purpose.
-*/
-struct DisplayCompatibility {
-  char c1;
-  int i1;
-  char c2;
-  int i2;
-};
-
-}  // namespace sde
-
-#endif  // __DISPLAY_TYPES_H__
-
diff --git a/displayengine/include/core/dump_interface.h b/displayengine/include/core/dump_interface.h
old mode 100644
new mode 100755
index acdc71f..20ab748
--- a/displayengine/include/core/dump_interface.h
+++ b/displayengine/include/core/dump_interface.h
@@ -31,7 +31,7 @@
 
 #include <stdint.h>
 
-#include "display_types.h"
+#include "sde_types.h"
 
 namespace sde {
 
diff --git a/displayengine/include/core/layer_buffer.h b/displayengine/include/core/layer_buffer.h
old mode 100644
new mode 100755
index 26b477c..5e813ea
--- a/displayengine/include/core/layer_buffer.h
+++ b/displayengine/include/core/layer_buffer.h
@@ -31,7 +31,7 @@
 
 #include <stdint.h>
 
-#include "display_types.h"
+#include "sde_types.h"
 
 namespace sde {
 
diff --git a/displayengine/include/core/layer_stack.h b/displayengine/include/core/layer_stack.h
old mode 100644
new mode 100755
index 6a99701..aa15753
--- a/displayengine/include/core/layer_stack.h
+++ b/displayengine/include/core/layer_stack.h
@@ -34,7 +34,7 @@
 #include <stdint.h>
 
 #include "layer_buffer.h"
-#include "display_types.h"
+#include "sde_types.h"
 
 namespace sde {
 
diff --git a/displayengine/include/core/sde_types.h b/displayengine/include/core/sde_types.h
new file mode 100755
index 0000000..6090889
--- /dev/null
+++ b/displayengine/include/core/sde_types.h
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without modification, are permitted
+* provided that the following conditions are met:
+*    * Redistributions of source code must retain the above copyright notice, this list of
+*      conditions and the following disclaimer.
+*    * Redistributions in binary form must reproduce the above copyright notice, this list of
+*      conditions and the following disclaimer in the documentation and/or other materials provided
+*      with the distribution.
+*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+*      endorse or promote products derived from this software without specific prior written
+*      permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*! @file sde_types.h
+  @brief This file contains miscellaneous data types used across display interfaces.
+*/
+#ifndef __SDE_TYPES_H__
+#define __SDE_TYPES_H__
+
+namespace sde {
+
+/*! @brief This enum represents different error codes that display interfaces may return.
+*/
+enum DisplayError {
+  kErrorNone,             //!< Call executed successfully.
+  kErrorUndefined,        //!< An unspecified error has occured.
+  kErrorNotSupported,     //!< Requested operation is not supported.
+  kErrorVersion,          //!< Client is using advanced version of interfaces and calling into an
+                          //!< older version of display library.
+  kErrorDataAlignment,    //!< Client data structures are not aligned on naturual boundaries.
+  kErrorInstructionSet,   //!< 32-bit client is calling into 64-bit library or vice versa.
+  kErrorParameters,       //!< Invalid parameters passed to a method.
+  kErrorFileDescriptor,   //!< Invalid file descriptor.
+  kErrorMemory,           //!< System is running low on memory.
+  kErrorResources,        //!< Not enough hardware resources available to execute call.
+  kErrorHardware,         //!< A hardware error has occured.
+  kErrorTimeOut,          //!< The operation has timed out to prevent client from waiting forever.
+};
+
+/*! @brief This enum represents different modules/logical unit tags that a log message may be
+  associated with. Client may use this to filter messages for dynamic logging.
+
+  @sa DisplayLogHandler
+*/
+enum LogTag {
+  kTagNone,             //!< Log is not tagged. This type of logs should always be printed.
+  kTagResources,        //!< Log is tagged for resource management.
+  kTagStrategy,         //!< Log is tagged for strategy decisions.
+};
+
+/*! @brief Display log handler class.
+
+  @details This class defines display log handler. The handle contains methods which client should
+  implement to get different levels of logging from display engine. Display engine will call into
+  these methods at appropriate times to send logging information.
+
+  @sa CoreInterface::CreateCore
+*/
+class LogHandler {
+ public:
+  /*! @brief Method to handle error messages.
+
+    @param[in] tag \link LogTag \endlink
+    @param[in] format \link message format with variable argument list \endlink
+  */
+  virtual void Error(LogTag tag, const char *format, ...) = 0;
+
+  /*! @brief Method to handle warning messages.
+
+    @param[in] tag \link LogTag \endlink
+    @param[in] format \link message format with variable argument list \endlink
+  */
+  virtual void Warning(LogTag tag, const char *format, ...) = 0;
+
+  /*! @brief Method to handle informative messages.
+
+    @param[in] tag \link LogTag \endlink
+    @param[in] format \link message format with variable argument list \endlink
+  */
+  virtual void Info(LogTag tag, const char *format, ...) = 0;
+
+  /*! @brief Method to handle verbose messages.
+
+    @param[in] tag \link LogTag \endlink
+    @param[in] format \link message format with variable argument list \endlink
+  */
+  virtual void Verbose(LogTag tag, const char *format, ...) = 0;
+
+ protected:
+  virtual ~LogHandler() { }
+};
+
+/*! @brief This structure is defined for client and library compatibility check purpose only. This
+  structure is used in SDE_VERSION_TAG definition only. Client should not refer it directly for
+  any purpose.
+*/
+struct SDECompatibility {
+  char c1;
+  int i1;
+  char c2;
+  int i2;
+};
+
+}  // namespace sde
+
+#endif  // __SDE_TYPES_H__
+
diff --git a/displayengine/include/private/strategy_interface.h b/displayengine/include/private/strategy_interface.h
index d4b8851..ee9763e 100755
--- a/displayengine/include/private/strategy_interface.h
+++ b/displayengine/include/private/strategy_interface.h
@@ -29,7 +29,7 @@
 #ifndef __STRATEGY_INTERFACE_H__
 #define __STRATEGY_INTERFACE_H__
 
-#include <core/display_types.h>
+#include <core/sde_types.h>
 
 namespace sde {
 
diff --git a/displayengine/include/utils/debug.h b/displayengine/include/utils/debug.h
old mode 100644
new mode 100755
index 0691dfc..8fbfb71
--- a/displayengine/include/utils/debug.h
+++ b/displayengine/include/utils/debug.h
@@ -25,45 +25,44 @@
 #ifndef __DEBUG_H__
 #define __DEBUG_H__
 
-#ifndef SDE_LOG_TAG
-#define SDE_LOG_TAG kLogTagNone
-#endif
+#include <core/sde_types.h>
 
-#ifndef SDE_MODULE_NAME
-#define SDE_MODULE_NAME "SDE"
-#endif
+#define DLOG(tag, method, format, ...) Debug::GetLogHandler()->method(tag, \
+                                            __CLASS__ "::%s: " format, __FUNCTION__, ##__VA_ARGS__)
 
-#define DLOG(method, format, ...) Debug::method(SDE_LOG_TAG, SDE_MODULE_NAME ": " format, \
-                                                ##__VA_ARGS__)
+#define DLOGE_IF(tag, format, ...) DLOG(tag, Error, format, ##__VA_ARGS__)
+#define DLOGW_IF(tag, format, ...) DLOG(tag, Warning, format, ##__VA_ARGS__)
+#define DLOGI_IF(tag, format, ...) DLOG(tag, Info, format, ##__VA_ARGS__)
+#define DLOGV_IF(tag, format, ...) DLOG(tag, Verbose, format, ##__VA_ARGS__)
 
-// SDE_LOG_TAG and SDE_MODULE_NAME must be defined before #include this header file in
-// respective module, else default definitions are used.
-#define DLOGE(format, ...) DLOG(Error, format, ##__VA_ARGS__)
-#define DLOGW(format, ...) DLOG(Warning, format, ##__VA_ARGS__)
-#define DLOGI(format, ...) DLOG(Info, format, ##__VA_ARGS__)
-#define DLOGV(format, ...) DLOG(Verbose, format, ##__VA_ARGS__)
+#define DLOGE(format, ...) DLOGE_IF(kTagNone, format, ##__VA_ARGS__)
+#define DLOGW(format, ...) DLOGW_IF(kTagNone, format, ##__VA_ARGS__)
+#define DLOGI(format, ...) DLOGI_IF(kTagNone, format, ##__VA_ARGS__)
+#define DLOGV(format, ...) DLOGV_IF(kTagNone, format, ##__VA_ARGS__)
 
 namespace sde {
 
-enum LogTag {
-  kTagNone = 0,   // Log tag name is not specified.
-  kTagCore,       // Log is tagged for display core.
-  kTagStrategy,   // Log is tagged for composition strategy.
-};
-
 class Debug {
  public:
-  // Log handlers
-  static void Error(const LogTag &tag, const char *format, ...);
-  static void Warning(const LogTag &tag, const char *format, ...);
-  static void Info(const LogTag &tag, const char *format, ...);
-  static void Verbose(const LogTag &tag, const char *format, ...);
-
-  // Debug properties
-  static bool IsVirtualDriver() { return debug_.virtual_driver_; }
+  static inline void SetLogHandler(LogHandler *log_handler) { debug_.log_handler_ = log_handler; }
+  static inline LogHandler* GetLogHandler() { return debug_.log_handler_; }
+  static inline bool IsVirtualDriver() { return debug_.virtual_driver_; }
 
  private:
   Debug();
+
+  // By default, drop any log messages coming from Display Engine. It will be overriden by Display
+  // Engine client when core is successfully initialized.
+  class DefaultLogHandler : public LogHandler {
+   public:
+    virtual void Error(LogTag /*tag*/, const char */*format*/, ...) { }
+    virtual void Warning(LogTag /*tag*/, const char */*format*/, ...) { }
+    virtual void Info(LogTag /*tag*/, const char */*format*/, ...) { }
+    virtual void Verbose(LogTag /*tag*/, const char */*format*/, ...) { }
+  };
+
+  DefaultLogHandler default_log_handler_;
+  LogHandler *log_handler_;
   bool virtual_driver_;
   static Debug debug_;
 };
diff --git a/displayengine/libs/core/comp_manager.cpp b/displayengine/libs/core/comp_manager.cpp
index eea861a..fa9349e 100755
--- a/displayengine/libs/core/comp_manager.cpp
+++ b/displayengine/libs/core/comp_manager.cpp
@@ -22,16 +22,14 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "CompManager"
-#include <utils/debug.h>
-
 #include <dlfcn.h>
 #include <utils/constants.h>
+#include <utils/debug.h>
 
 #include "comp_manager.h"
 
+#define __CLASS__ "CompManager"
+
 namespace sde {
 
 CompManager::CompManager() : strategy_lib_(NULL), strategy_intf_(NULL), registered_displays_(0),
diff --git a/displayengine/libs/core/core_impl.cpp b/displayengine/libs/core/core_impl.cpp
old mode 100644
new mode 100755
index a3dfde1..0669f9f
--- a/displayengine/libs/core/core_impl.cpp
+++ b/displayengine/libs/core/core_impl.cpp
@@ -22,19 +22,17 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "CoreImpl"
-#include <utils/debug.h>
-
 #include <utils/locker.h>
 #include <utils/constants.h>
+#include <utils/debug.h>
 
 #include "core_impl.h"
 #include "display_primary.h"
 #include "display_hdmi.h"
 #include "display_virtual.h"
 
+#define __CLASS__ "CoreImpl"
+
 namespace sde {
 
 CoreImpl::CoreImpl(CoreEventHandler *event_handler)
diff --git a/displayengine/libs/core/core_interface.cpp b/displayengine/libs/core/core_interface.cpp
index 51bb588..fb8700a 100755
--- a/displayengine/libs/core/core_interface.cpp
+++ b/displayengine/libs/core/core_interface.cpp
@@ -22,16 +22,14 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "CoreInterface"
-#include <utils/debug.h>
-
 #include <utils/locker.h>
 #include <utils/constants.h>
+#include <utils/debug.h>
 
 #include "core_impl.h"
 
+#define __CLASS__ "CoreInterface"
+
 #define GET_REVISION(version) (version >> 16)
 #define GET_DATA_ALIGNMENT(version) ((version >> 8) & 0xFF)
 #define GET_INSTRUCTION_SET(version) (version & 0xFF)
@@ -47,16 +45,16 @@
   Locker locker;
 } g_core;
 
-DisplayError CoreInterface::CreateCore(CoreEventHandler *event_handler, CoreInterface **interface,
-                                 uint32_t client_version) {
+DisplayError CoreInterface::CreateCore(CoreEventHandler *event_handler, LogHandler *log_handler,
+                                       CoreInterface **interface, uint32_t client_version) {
   SCOPE_LOCK(g_core.locker);
 
-  if (UNLIKELY(!event_handler || !interface)) {
+  if (UNLIKELY(!event_handler || !log_handler || !interface)) {
     return kErrorParameters;
   }
 
   // Check compatibility of client and core.
-  uint32_t lib_version = CORE_VERSION_TAG;
+  uint32_t lib_version = SDE_VERSION_TAG;
   if (UNLIKELY(GET_REVISION(client_version) > GET_REVISION(lib_version))) {
     return kErrorVersion;
   } else if (UNLIKELY(GET_DATA_ALIGNMENT(client_version) != GET_DATA_ALIGNMENT(lib_version))) {
@@ -67,10 +65,11 @@
 
   CoreImpl *&core_impl = g_core.core_impl;
   if (UNLIKELY(core_impl)) {
-    DLOGE("Only one display core session is supported at present.");
     return kErrorUndefined;
   }
 
+  Debug::SetLogHandler(log_handler);
+
   // Create appropriate CoreImpl object based on client version.
   if (GET_REVISION(client_version) == CoreImpl::kRevision) {
     core_impl = new CoreImpl(event_handler);
diff --git a/displayengine/libs/core/display_base.cpp b/displayengine/libs/core/display_base.cpp
old mode 100644
new mode 100755
index f731be5..6099231
--- a/displayengine/libs/core/display_base.cpp
+++ b/displayengine/libs/core/display_base.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DisplayBase"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "display_base.h"
 
+#define __CLASS__ "DisplayBase"
+
 namespace sde {
 
 DisplayBase::DisplayBase(DisplayType display_type, DisplayEventHandler *event_handler,
@@ -224,7 +222,7 @@
 
   DisplayError error = kErrorNone;
 
-  DLOGI("Set state: %d", state);
+  DLOGI("Set state = %d", state);
 
   if (UNLIKELY(state == state_)) {
     DLOGI("Same state transition is requested.");
@@ -251,7 +249,7 @@
     break;
 
   default:
-    DLOGE("Spurious state %d transition requested.", state);
+    DLOGE("Spurious state = %d transition requested.", state);
     break;
   }
 
diff --git a/displayengine/libs/core/display_hdmi.cpp b/displayengine/libs/core/display_hdmi.cpp
old mode 100644
new mode 100755
index 546e74d..48208bf
--- a/displayengine/libs/core/display_hdmi.cpp
+++ b/displayengine/libs/core/display_hdmi.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DisplayHDMI"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "display_hdmi.h"
 
+#define __CLASS__ "DisplayHDMI"
+
 namespace sde {
 
 DisplayHDMI::DisplayHDMI(DisplayEventHandler *event_handler, HWInterface *hw_intf,
diff --git a/displayengine/libs/core/display_primary.cpp b/displayengine/libs/core/display_primary.cpp
old mode 100644
new mode 100755
index 388e90a..e4bd031
--- a/displayengine/libs/core/display_primary.cpp
+++ b/displayengine/libs/core/display_primary.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DisplayPrimary"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "display_primary.h"
 
+#define __CLASS__ "DisplayPrimary"
+
 namespace sde {
 
 DisplayPrimary::DisplayPrimary(DisplayEventHandler *event_handler, HWInterface *hw_intf,
diff --git a/displayengine/libs/core/display_virtual.cpp b/displayengine/libs/core/display_virtual.cpp
old mode 100644
new mode 100755
index bfa3927..2fef178
--- a/displayengine/libs/core/display_virtual.cpp
+++ b/displayengine/libs/core/display_virtual.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DisplayVirtual"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "display_virtual.h"
 
+#define __CLASS__ "DisplayVirtual"
+
 namespace sde {
 
 DisplayVirtual::DisplayVirtual(DisplayEventHandler *event_handler, HWInterface *hw_intf,
diff --git a/displayengine/libs/core/dump_impl.cpp b/displayengine/libs/core/dump_impl.cpp
old mode 100644
new mode 100755
index b000ea7..a5aca81
--- a/displayengine/libs/core/dump_impl.cpp
+++ b/displayengine/libs/core/dump_impl.cpp
@@ -22,11 +22,6 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "DumpInterface"
-#include <utils/debug.h>
-
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/displayengine/libs/core/hw_framebuffer.cpp b/displayengine/libs/core/hw_framebuffer.cpp
old mode 100644
new mode 100755
index 6900bb8..69b4a58
--- a/displayengine/libs/core/hw_framebuffer.cpp
+++ b/displayengine/libs/core/hw_framebuffer.cpp
@@ -22,11 +22,7 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "HWFrameBuffer"
 #define __STDC_FORMAT_MACROS
-#include <utils/debug.h>
 
 #include <math.h>
 #include <fcntl.h>
@@ -39,9 +35,12 @@
 #include <sys/prctl.h>
 #include <pthread.h>
 #include <utils/constants.h>
+#include <utils/debug.h>
 
 #include "hw_framebuffer.h"
 
+#define __CLASS__ "HWFrameBuffer"
+
 #define IOCTL_LOGE(ioctl) DLOGE("ioctl %s, errno = %d, desc = %s", #ioctl, errno, strerror(errno))
 
 #ifdef DISPLAY_CORE_VIRTUAL_DRIVER
@@ -383,7 +382,7 @@
 
   mdp_commit.flags |= MDP_VALIDATE_LAYER;
   if (ioctl_(hw_context->device_fd, MSMFB_ATOMIC_COMMIT, &hw_context->mdp_commit) == -1) {
-    IOCTL_LOGE("validate:"MSMFB_ATOMIC_COMMIT);
+    IOCTL_LOGE(MSMFB_ATOMIC_COMMIT);
     return kErrorHardware;
   }
 
@@ -425,7 +424,7 @@
   mdp_commit.flags |= MDP_COMMIT_RETIRE_FENCE;
   mdp_commit.flags &= ~MDP_VALIDATE_LAYER;
   if (ioctl_(hw_context->device_fd, MSMFB_ATOMIC_COMMIT, &hw_context->mdp_commit) == -1) {
-    IOCTL_LOGE("commit:"MSMFB_ATOMIC_COMMIT);
+    IOCTL_LOGE(MSMFB_ATOMIC_COMMIT);
     return kErrorHardware;
   }
 
@@ -521,7 +520,7 @@
   while (!exit_threads_) {
     int error = poll_(poll_fds_[0], kNumPhysicalDisplays * kNumDisplayEvents, -1);
     if (error < 0) {
-      DLOGW("poll failed errno: %s", strerror(errno));
+      DLOGW("poll failed. error = %s", strerror(errno));
       continue;
     }
 
@@ -533,7 +532,8 @@
           ssize_t length = pread_(poll_fd.fd, data, kMaxStringLength, 0);
           if (length < 0) {
             // If the read was interrupted - it is not a fatal error, just continue.
-            DLOGW("Failed to read event:%d for display=%d: %s", event, display, strerror(errno));
+            DLOGW("pread failed. event = %d, display = %d, error = %s",
+                                                      event, display, strerror(errno));
             continue;
           }
 
@@ -750,18 +750,18 @@
     }
   }
 
-  DLOGI("SDE Version: %d SDE Revision: %x RGB : %d, VIG: %d DMA: %d Cursor: %d",
+  DLOGI("SDE Version = %d, SDE Revision = %x, RGB = %d, VIG = %d, DMA = %d, Cursor = %d",
         hw_resource_.hw_version, hw_resource_.hw_revision, hw_resource_.num_rgb_pipe,
         hw_resource_.num_vig_pipe, hw_resource_.num_dma_pipe, hw_resource_.num_cursor_pipe);
-  DLOGI("Upscale Ratio: %d Downscale Ratio: %d Blending Stages: %d", hw_resource_.max_scale_up,
+  DLOGI("Upscale Ratio = %d, Downscale Ratio = %d, Blending Stages = %d", hw_resource_.max_scale_up,
         hw_resource_.max_scale_down, hw_resource_.num_blending_stages);
-  DLOGI("BWC: %d Decimation: %d Tile Format: %d: Rotator Downscale: %d",  hw_resource_.has_bwc,
+  DLOGI("BWC = %d, Decimation = %d, Tile Format = %d, Rotator Downscale = %d", hw_resource_.has_bwc,
         hw_resource_.has_decimation, hw_resource_.has_macrotile,
         hw_resource_.has_rotator_downscale);
-  DLOGI("Left Split: %d Right Split: %d", hw_resource_.split_info.left_split,
+  DLOGI("Left Split = %d, Right Split = %d", hw_resource_.split_info.left_split,
         hw_resource_.split_info.right_split);
-  DLOGI("SourceSplit: %d Always: %d", hw_resource_.is_src_split, hw_resource_.always_src_split);
-  DLOGI("MaxLowBw: %"PRIu64" MaxHighBw: %"PRIu64"", hw_resource_.max_bandwidth_low,
+  DLOGI("SourceSplit = %d, Always = %d", hw_resource_.is_src_split, hw_resource_.always_src_split);
+  DLOGI("MaxLowBw = %"PRIu64", MaxHighBw = %"PRIu64"", hw_resource_.max_bandwidth_low,
         hw_resource_.max_bandwidth_high);
 
   return error;
diff --git a/displayengine/libs/core/hw_interface.cpp b/displayengine/libs/core/hw_interface.cpp
old mode 100644
new mode 100755
index f39cc21..3ab0c7e
--- a/displayengine/libs/core/hw_interface.cpp
+++ b/displayengine/libs/core/hw_interface.cpp
@@ -22,11 +22,6 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "HWInterface"
-#include <utils/debug.h>
-
 #include <utils/constants.h>
 
 #include "hw_interface.h"
diff --git a/displayengine/libs/core/offline_ctrl.cpp b/displayengine/libs/core/offline_ctrl.cpp
old mode 100644
new mode 100755
index be01cef..c380d52
--- a/displayengine/libs/core/offline_ctrl.cpp
+++ b/displayengine/libs/core/offline_ctrl.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "OfflineCtrl"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "offline_ctrl.h"
 
+#define __CLASS__ "OfflineCtrl"
+
 namespace sde {
 
 OfflineCtrl::OfflineCtrl() : hw_intf_(NULL) {
diff --git a/displayengine/libs/core/res_config.cpp b/displayengine/libs/core/res_config.cpp
old mode 100644
new mode 100755
index 3831eb3..e1b5320
--- a/displayengine/libs/core/res_config.cpp
+++ b/displayengine/libs/core/res_config.cpp
@@ -22,16 +22,14 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "ResConfig"
+#include <math.h>
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-#include <math.h>
-
 #include "res_manager.h"
 
+#define __CLASS__ "ResManager"
+
 namespace sde {
 
 DisplayError ResManager::Config(DisplayResourceContext *display_resource_ctx, HWLayers *hw_layers) {
diff --git a/displayengine/libs/core/res_manager.cpp b/displayengine/libs/core/res_manager.cpp
old mode 100644
new mode 100755
index 7439f1a..ee1b25f
--- a/displayengine/libs/core/res_manager.cpp
+++ b/displayengine/libs/core/res_manager.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "ResManager"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "res_manager.h"
 
+#define __CLASS__ "ResManager"
+
 namespace sde {
 
 ResManager::ResManager()
@@ -38,8 +36,6 @@
 }
 
 DisplayError ResManager::Init(const HWResourceInfo &hw_res_info) {
-  DLOGV("Init");
-
   hw_res_info_ = hw_res_info;
 
   DisplayError error = kErrorNone;
@@ -280,21 +276,21 @@
   HWBlockType hw_block_id = display_resource_ctx->hw_block_id;
   uint64_t frame_count = display_resource_ctx->frame_count;
 
-  DLOGV("Resource for hw_block=%d frame_count=%d", hw_block_id, frame_count);
+  DLOGV_IF(kTagResources, "Resource for hw_block = %d, frame_count = %d", hw_block_id, frame_count);
 
   for (uint32_t i = 0; i < num_pipe_; i++) {
     if (src_pipes_[i].reserved) {
       src_pipes_[i].hw_block_id = hw_block_id;
       src_pipes_[i].state = kPipeStateAcquired;
       src_pipes_[i].state_frame_count = frame_count;
-      DLOGV("Pipe acquired index=%d type=%d pipe_id=%x", i, src_pipes_[i].type,
-            src_pipes_[i].mdss_pipe_id);
+      DLOGV_IF(kTagResources, "Pipe acquired index = %d, type = %d, pipe_id = %x", i,
+            src_pipes_[i].type, src_pipes_[i].mdss_pipe_id);
     } else if ((src_pipes_[i].hw_block_id == hw_block_id) &&
                (src_pipes_[i].state == kPipeStateAcquired)) {
       src_pipes_[i].state = kPipeStateToRelease;
       src_pipes_[i].state_frame_count = frame_count;
-      DLOGV("Pipe to release index=%d type=%d pipe_id=%x", i, src_pipes_[i].type,
-            src_pipes_[i].mdss_pipe_id);
+      DLOGV_IF(kTagResources, "Pipe to release index = %d, type = %d, pipe_id = %x", i,
+            src_pipes_[i].type, src_pipes_[i].mdss_pipe_id);
     }
   }
 
diff --git a/displayengine/libs/core/strategy_default.cpp b/displayengine/libs/core/strategy_default.cpp
index 8bf5a87..6963c6c 100755
--- a/displayengine/libs/core/strategy_default.cpp
+++ b/displayengine/libs/core/strategy_default.cpp
@@ -22,15 +22,13 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-// SDE_LOG_TAG definition must precede debug.h include.
-#define SDE_LOG_TAG kTagCore
-#define SDE_MODULE_NAME "StrategyDefault"
+#include <utils/constants.h>
 #include <utils/debug.h>
 
-#include <utils/constants.h>
-
 #include "strategy_default.h"
 
+#define __CLASS__ "StrategyDefault"
+
 namespace sde {
 
 DisplayError StrategyDefault::GetNextStrategy(StrategyConstraints *constraints,
diff --git a/displayengine/libs/hwc/Android.mk b/displayengine/libs/hwc/Android.mk
old mode 100644
new mode 100755
index c32337a..a8f6464
--- a/displayengine/libs/hwc/Android.mk
+++ b/displayengine/libs/hwc/Android.mk
@@ -6,7 +6,7 @@
 LOCAL_MODULE_RELATIVE_PATH    := hw
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes) $(kernel_includes)
-LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"HWComposer\"
+LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"SDE\"
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libEGL libhardware_legacy \
                                  libdl libsync \
                                  libbinder libmedia libskia libsde
@@ -15,6 +15,7 @@
                                  hwc_display.cpp \
                                  hwc_display_primary.cpp \
                                  hwc_display_external.cpp \
-                                 hwc_display_virtual.cpp
+                                 hwc_display_virtual.cpp \
+                                 hwc_logger.cpp
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/displayengine/libs/hwc/hwc_display.cpp b/displayengine/libs/hwc/hwc_display.cpp
index 4238ea2..7654e9a 100644
--- a/displayengine/libs/hwc/hwc_display.cpp
+++ b/displayengine/libs/hwc/hwc_display.cpp
@@ -26,11 +26,10 @@
 #include <gralloc_priv.h>
 #include <utils/constants.h>
 
-// HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCDisplay"
+#include "hwc_display.h"
 #include "hwc_logger.h"
 
-#include "hwc_display.h"
+#define __CLASS__ "HWCDisplay"
 
 namespace sde {
 
@@ -42,7 +41,7 @@
 int HWCDisplay::Init() {
   DisplayError error = core_intf_->CreateDisplay(type_, this, &display_intf_);
   if (UNLIKELY(error != kErrorNone)) {
-    DLOGE("Display device create failed. Error = %d", error);
+    DLOGE("Display create failed. Error = %d", error);
     return -EINVAL;
   }
 
@@ -52,7 +51,7 @@
 int HWCDisplay::Deinit() {
   DisplayError error = core_intf_->DestroyDisplay(display_intf_);
   if (UNLIKELY(error != kErrorNone)) {
-    DLOGE("Display device destroy failed. Error = %d", error);
+    DLOGE("Display destroy failed. Error = %d", error);
     return -EINVAL;
   }
 
@@ -74,11 +73,11 @@
     // TODO(user): Need to handle this case
     break;
   default:
-    DLOGW("Unsupported event control type : %d", event);
+    DLOGW("Unsupported event = %d", event);
   }
 
   if (UNLIKELY(error != kErrorNone)) {
-    DLOGE("EventControl failed. event = %d, enable = %d, error = %d", event, enable, error);
+    DLOGE("Failed. event = %d, enable = %d, error = %d", event, enable, error);
     return -EINVAL;
   }
 
@@ -86,7 +85,7 @@
 }
 
 int HWCDisplay::Blank(int blank) {
-  DLOGI("Blank : %d, display : %d", blank, id_);
+  DLOGI("blank = %d, display = %d", blank, id_);
   DisplayState state = blank ? kStateOff : kStateOn;
   return SetState(state);
 }
@@ -128,7 +127,7 @@
       values[i] = INT32(variable_config.y_dpi * 1000.0f);
       break;
     default:
-      DLOGW("Spurious attribute type %d", attributes[i]);
+      DLOGW("Spurious attribute type = %d", attributes[i]);
       return -EINVAL;
     }
   }
@@ -465,7 +464,7 @@
   case HAL_PIXEL_FORMAT_RGB_565:              *target = kFormatRGB565;                    break;
   case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:   *target = kFormatYCbCr420SemiPlanarVenus;   break;
   default:
-    DLOGW("Unsupported format type %d", source);
+    DLOGW("Unsupported format type = %d", source);
     return -EINVAL;
   }
 
diff --git a/displayengine/libs/hwc/hwc_display_external.cpp b/displayengine/libs/hwc/hwc_display_external.cpp
old mode 100644
new mode 100755
index 8334605..386e713
--- a/displayengine/libs/hwc/hwc_display_external.cpp
+++ b/displayengine/libs/hwc/hwc_display_external.cpp
@@ -24,11 +24,10 @@
 
 #include <utils/constants.h>
 
-// HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCDisplayExternal"
+#include "hwc_display_external.h"
 #include "hwc_logger.h"
 
-#include "hwc_display_external.h"
+#define __CLASS__ "HWCDisplayExternal"
 
 namespace sde {
 
diff --git a/displayengine/libs/hwc/hwc_display_primary.cpp b/displayengine/libs/hwc/hwc_display_primary.cpp
old mode 100644
new mode 100755
index b23d89c..95dc97e
--- a/displayengine/libs/hwc/hwc_display_primary.cpp
+++ b/displayengine/libs/hwc/hwc_display_primary.cpp
@@ -24,11 +24,10 @@
 
 #include <utils/constants.h>
 
-// HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCDisplayPrimary"
+#include "hwc_display_primary.h"
 #include "hwc_logger.h"
 
-#include "hwc_display_primary.h"
+#define __CLASS__ "HWCDisplayPrimary"
 
 namespace sde {
 
diff --git a/displayengine/libs/hwc/hwc_display_virtual.cpp b/displayengine/libs/hwc/hwc_display_virtual.cpp
old mode 100644
new mode 100755
index 62e4d2f..3ac2376
--- a/displayengine/libs/hwc/hwc_display_virtual.cpp
+++ b/displayengine/libs/hwc/hwc_display_virtual.cpp
@@ -24,11 +24,10 @@
 
 #include <utils/constants.h>
 
-// HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCDisplayVirtual"
+#include "hwc_display_virtual.h"
 #include "hwc_logger.h"
 
-#include "hwc_display_virtual.h"
+#define __CLASS__ "HWCDisplayVirtual"
 
 namespace sde {
 
diff --git a/displayengine/libs/hwc/hwc_logger.cpp b/displayengine/libs/hwc/hwc_logger.cpp
new file mode 100755
index 0000000..b868a90
--- /dev/null
+++ b/displayengine/libs/hwc/hwc_logger.cpp
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without modification, are permitted
+* provided that the following conditions are met:
+*    * Redistributions of source code must retain the above copyright notice, this list of
+*      conditions and the following disclaimer.
+*    * Redistributions in binary form must reproduce the above copyright notice, this list of
+*      conditions and the following disclaimer in the documentation and/or other materials provided
+*      with the distribution.
+*    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+*      endorse or promote products derived from this software without specific prior written
+*      permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "hwc_logger.h"
+
+namespace sde {
+
+HWCLogHandler HWCLogHandler::log_handler_;
+
+void HWCLogHandler::Error(LogTag /*tag*/, const char *format, ...) {
+  va_list list;
+  va_start(list, format);
+  __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, list);
+}
+
+void HWCLogHandler::Warning(LogTag /*tag*/, const char *format, ...) {
+  va_list list;
+  va_start(list, format);
+  __android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, format, list);
+}
+
+void HWCLogHandler::Info(LogTag /*tag*/, const char *format, ...) {
+  va_list list;
+  va_start(list, format);
+  __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, list);
+}
+
+void HWCLogHandler::Verbose(LogTag /*tag*/, const char *format, ...) {
+  va_list list;
+  va_start(list, format);
+  __android_log_vprint(ANDROID_LOG_VERBOSE, LOG_TAG, format, list);
+}
+
+}  // namespace sde
+
diff --git a/displayengine/libs/hwc/hwc_logger.h b/displayengine/libs/hwc/hwc_logger.h
old mode 100644
new mode 100755
index cee38e9..13c2e20
--- a/displayengine/libs/hwc/hwc_logger.h
+++ b/displayengine/libs/hwc/hwc_logger.h
@@ -25,20 +25,32 @@
 #ifndef __HWC_LOGGER_H__
 #define __HWC_LOGGER_H__
 
+#include <core/sde_types.h>
 #include <cutils/log.h>
 
-#ifndef HWC_MODULE_NAME
-#define HWC_MODULE_NAME "HWComposer"
-#endif
+#define DLOG(Macro, format, ...) Macro(__CLASS__ "::%s: " format, __FUNCTION__, ##__VA_ARGS__)
 
-#define HWC_LOG(Macro, format, ...) Macro(HWC_MODULE_NAME ": " format, ##__VA_ARGS__)
+#define DLOGE(format, ...) DLOG(ALOGE, format, ##__VA_ARGS__)
+#define DLOGW(format, ...) DLOG(ALOGW, format, ##__VA_ARGS__)
+#define DLOGI(format, ...) DLOG(ALOGI, format, ##__VA_ARGS__)
+#define DLOGV(format, ...) DLOG(ALOGV, format, ##__VA_ARGS__)
 
-// HWC_MODULE_NAME must be defined before #include this header file in respective
-// module, else default definition is used.
-#define DLOGE(format, ...) HWC_LOG(ALOGE, format, ##__VA_ARGS__)
-#define DLOGW(format, ...) HWC_LOG(ALOGW, format, ##__VA_ARGS__)
-#define DLOGI(format, ...) HWC_LOG(ALOGI, format, ##__VA_ARGS__)
-#define DLOGV(format, ...) HWC_LOG(ALOGV, format, ##__VA_ARGS__)
+namespace sde {
+
+class HWCLogHandler : public LogHandler {
+ public:
+  virtual void Error(LogTag tag, const char *format, ...);
+  virtual void Warning(LogTag tag, const char *format, ...);
+  virtual void Info(LogTag tag, const char *format, ...);
+  virtual void Verbose(LogTag tag, const char *format, ...);
+
+  static inline LogHandler* Get() { return &log_handler_; }
+
+ private:
+  static HWCLogHandler log_handler_;
+};
+
+}  // namespace sde
 
 #endif  // __HWC_LOGGER_H__
 
diff --git a/displayengine/libs/hwc/hwc_session.cpp b/displayengine/libs/hwc/hwc_session.cpp
old mode 100644
new mode 100755
index c73b2b3..9604782
--- a/displayengine/libs/hwc/hwc_session.cpp
+++ b/displayengine/libs/hwc/hwc_session.cpp
@@ -25,11 +25,10 @@
 #include <core/dump_interface.h>
 #include <utils/constants.h>
 
-// HWC_MODULE_NAME definition must precede hwc_logger.h include.
-#define HWC_MODULE_NAME "HWCSession"
+#include "hwc_session.h"
 #include "hwc_logger.h"
 
-#include "hwc_session.h"
+#define __CLASS__ "HWCSession"
 
 static sde::HWCSession::HWCModuleMethods g_hwc_module_methods;
 
@@ -68,7 +67,7 @@
 }
 
 int HWCSession::Init() {
-  DisplayError error = CoreInterface::CreateCore(this, &core_intf_);
+  DisplayError error = CoreInterface::CreateCore(this, HWCLogHandler::Get(), &core_intf_);
   if (UNLIKELY(error != kErrorNone)) {
     DLOGE("Display core initialization failed. Error = %d", error);
     return -EINVAL;
@@ -116,7 +115,7 @@
 
 int HWCSession::Open(const hw_module_t *module, const char *name, hw_device_t **device) {
   if (UNLIKELY(!module || !name || !device)) {
-    DLOGE("::%s Invalid parameters.", __FUNCTION__);
+    DLOGE("Invalid parameters.");
     return -EINVAL;
   }
 
@@ -167,7 +166,7 @@
   for (size_t i = 0; i < num_displays; i++) {
     hwc_display_contents_1_t *content_list = displays[i];
     if (UNLIKELY(!content_list || !content_list->numHwLayers)) {
-      DLOGW("::%s Invalid content list.", __FUNCTION__);
+      DLOGW("Invalid content list.");
       return -EINVAL;
     }
 
@@ -201,7 +200,7 @@
   for (size_t i = 0; i < num_displays; i++) {
     hwc_display_contents_1_t *content_list = displays[i];
     if (UNLIKELY(!content_list || !content_list->numHwLayers)) {
-      DLOGW("::%s Invalid content list.", __FUNCTION__);
+      DLOGW("Invalid content list.");
       return -EINVAL;
     }
 
diff --git a/displayengine/libs/utils/debug_android.cpp b/displayengine/libs/utils/debug_android.cpp
old mode 100644
new mode 100755
index 09b32fe..23da9fe
--- a/displayengine/libs/utils/debug_android.cpp
+++ b/displayengine/libs/utils/debug_android.cpp
@@ -31,36 +31,12 @@
 
 Debug Debug::debug_;
 
-Debug::Debug() : virtual_driver_(false) {
+Debug::Debug() : log_handler_(&default_log_handler_), virtual_driver_(false) {
   char property[PROPERTY_VALUE_MAX];
   if (property_get("displaycore.virtualdriver", property, NULL) > 0) {
     virtual_driver_ = (atoi(property) == 1);
   }
 }
 
-void Debug::Error(const LogTag & /*tag*/, const char *format, ...) {
-  va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, list);
-}
-
-void Debug::Warning(const LogTag & /*tag*/, const char *format, ...) {
-  va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, format, list);
-}
-
-void Debug::Info(const LogTag & /*tag*/, const char *format, ...) {
-  va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, list);
-}
-
-void Debug::Verbose(const LogTag & /*tag*/, const char *format, ...) {
-  va_list list;
-  va_start(list, format);
-  __android_log_vprint(ANDROID_LOG_VERBOSE, LOG_TAG, format, list);
-}
-
 }  // namespace sde