blob: f2f5fde53001c806379077f19593a78377c1df90 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "pagespeed/kernel/base/annotated_message_handler.h"
#include "pagespeed/kernel/base/message_handler.h"
#include "pagespeed/kernel/base/string.h"
#include "pagespeed/kernel/base/string_util.h"
namespace net_instaweb {
AnnotatedMessageHandler::AnnotatedMessageHandler(MessageHandler* handler) :
message_handler_(handler) {
}
AnnotatedMessageHandler::AnnotatedMessageHandler(const GoogleString& annotation,
MessageHandler* handler) :
message_handler_(handler) {
annotation_ = annotation;
}
AnnotatedMessageHandler::~AnnotatedMessageHandler() {
}
void AnnotatedMessageHandler::MessageVImpl(MessageType type, const char* msg,
va_list args) {
GoogleString buffer(annotation_);
FormatTo(&buffer, msg, args);
message_handler_->MessageS(type, buffer);
}
void AnnotatedMessageHandler::MessageSImpl(
MessageType type, const GoogleString& message) {
GoogleString buffer = StrCat(annotation_, message);
message_handler_->MessageS(type, buffer);
}
void AnnotatedMessageHandler::FileMessageVImpl(MessageType type,
const char* filename,
int line,
const char* msg,
va_list args) {
GoogleString buffer(annotation_);
FormatTo(&buffer, msg, args);
message_handler_->FileMessageS(type, filename, line, buffer);
}
void AnnotatedMessageHandler::FileMessageSImpl(
MessageType type, const char* filename, int line,
const GoogleString& message) {
GoogleString buffer = StrCat(annotation_, message);
message_handler_->FileMessageS(type, filename, line, buffer);
}
} // namespace net_instaweb