blob: cc0cc2d8f130a7712a154255e4000aa586dfeb3a [file] [log] [blame]
edisonn@google.com67d7fb42013-10-07 15:40:21 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9#include "SkPdfReporter.h"
10
11#include "SkTypes.h"
12
13const char* severityName[] = {
14"Info",
15"CodeWarning",
16"Warning",
17"IgnoreError",
18"Error",
19"FatalError",
20};
21
22const char* getSeverityName(SkPdfIssueSeverity sev) {
23 if (0 <= sev && sev < _kCount__SkPdfIssueSeverity) {
24 return severityName[sev];
25 }
26 SkASSERT(false);
27 return "UNKOWN SEVERITY";
28}
29
30// TODO(edisonn): add a flag to set the minimum warning level
31
32#ifdef PDF_REPORT
33void SkPdfReport( SkPdfIssueSeverity sev, SkPdfIssue issue, const char* context, const SkPdfNativeObject* obj, SkPdfContext* pdfContext) {
34 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
35 printf("%s: %s\n", getSeverityName(sev), context);
36 }
37}
38
39void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, const char* context, const SkPdfNativeObject* obj, int anyOfTypes, SkPdfContext* pdfContext) {
40 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
41 printf("%s: %s\n", getSeverityName(sev), context);
42 }
43}
44
45void SkPdfReportIf(bool report, SkPdfIssueSeverity sev, SkPdfIssue issue, const char* context, const SkPdfNativeObject* obj, SkPdfContext* pdfContext) {
46 if (!report) {
47 return;
48 }
49 SkPdfReport(sev, issue, context, obj, pdfContext);
50}
51#endif // PDF_REPORT