Home | History | Annotate | Download | only in ports
      1 
      2 /*
      3  * Copyright 2012 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 
     11 #include "SkTypes.h"
     12 
     13 static const size_t kBufferSize = 2048;
     14 
     15 #include <stdarg.h>
     16 #include <stdio.h>
     17 
     18 #include "ppapi/cpp/instance.h"
     19 #include "ppapi/cpp/var.h"
     20 
     21 extern pp::Instance* gPluginInstance;
     22 
     23 namespace {
     24 static const char* kLogPrefix = "SkDebugf:";
     25 }
     26 
     27 void SkDebugf(const char format[], ...) {
     28     if (gPluginInstance) {
     29         char buffer[kBufferSize + 1];
     30         va_list args;
     31         va_start(args, format);
     32         sprintf(buffer, kLogPrefix);
     33         vsnprintf(buffer + strlen(kLogPrefix), kBufferSize, format, args);
     34         va_end(args);
     35         pp::Var msg = pp::Var(buffer);
     36         gPluginInstance->PostMessage(msg);
     37     }
     38 }
     39