Browse Source

CPP: Exclude the logging-related code when the library is built in Chromium.

pull/567/head
Philippe Liard 15 years ago
committed by Mihaela Rosca
parent
commit
3481afa6a0
2 changed files with 28 additions and 0 deletions
  1. +5
    -0
      cpp/src/phonenumbers/default_logger.cc
  2. +23
    -0
      cpp/src/phonenumbers/default_logger.h

+ 5
- 0
cpp/src/phonenumbers/default_logger.cc View File

@ -14,6 +14,9 @@
// Author: Philippe Liard
// This file should not be compiled when using Google base/.
#ifndef USE_GOOGLE_BASE
#include <iostream>
#include "phonenumbers/default_logger.h"
@ -47,3 +50,5 @@ void StdoutLogger::WriteLevel() {
} // namespace phonenumbers
} // namespace i18n
#endif // USE_GOOGLE_BASE

+ 23
- 0
cpp/src/phonenumbers/default_logger.h View File

@ -17,6 +17,28 @@
#ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#ifdef USE_GOOGLE_BASE
namespace i18n {
namespace phonenumbers {
// If Google base/ is used, LOG() and VLOG() from base/logging.h are used
// therefore the default logger implementation (StdoutLogger) instantiated in
// phonenumberutil will actually never be used. Thus provide a dummy
// implementation of this logger.
class StdoutLogger : public Logger {
public:
virtual ~StdoutLogger() {}
virtual void WriteLevel() {}
virtual void WriteMessage(const string& /* msg */) {}
};
} // namespace phonenumbers
} // namespace i18n
#else
#include <string>
#include "phonenumbers/logger.h"
@ -103,4 +125,5 @@ class StdoutLogger : public Logger {
} // namespace phonenumbers
} // namespace i18n
#endif // USE_GOOGLE_BASE
#endif // I18N_PHONENUMBERS_DEFAULT_LOGGER_H_

Loading…
Cancel
Save