blob: 4506c33c0b1f82e5d5dd55546a4dbc6611cf23d2 [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
edisonn@google.come50d9a12013-10-10 20:58:22 +000033void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue,
34 const char* context,
35 const SkPdfNativeObject* obj,
36 SkPdfContext* pdfContext) {
edisonn@google.com67d7fb42013-10-07 15:40:21 +000037 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
38 printf("%s: %s\n", getSeverityName(sev), context);
39 }
40}
41
edisonn@google.come50d9a12013-10-10 20:58:22 +000042void SkPdfReportIf(bool report,
43 SkPdfIssueSeverity sev, SkPdfIssue issue,
44 const char* context,
45 const SkPdfNativeObject* obj,
46SkPdfContext* pdfContext) {
edisonn@google.com67d7fb42013-10-07 15:40:21 +000047 if (!report) {
48 return;
49 }
50 SkPdfReport(sev, issue, context, obj, pdfContext);
51}
edisonn@google.come50d9a12013-10-10 20:58:22 +000052
53void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev,
54 const char* context,
55 const SkPdfNativeObject* obj,
56 int anyOfTypes, SkPdfContext* pdfContext) {
57 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
58 printf("%s: %s\n", getSeverityName(sev), context);
59 }
60}
61
edisonn@google.com67d7fb42013-10-07 15:40:21 +000062#endif // PDF_REPORT