• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/scheduler/hilog-helper.c b/scheduler/hilog-helper.c
2new file mode 100644
3index 0000000..28d986d
4--- /dev/null
5+++ b/scheduler/hilog-helper.c
6@@ -0,0 +1,29 @@
7+/*
8+ * Copyright (c) 2024 Huawei Device Co., Ltd.
9+ * Licensed under the Apache License, Version 2.0 (the "License");
10+ * you may not use this file except in compliance with the License.
11+ * You may obtain a copy of the License at
12+ *
13+ *     http://www.apache.org/licenses/LICENSE-2.0
14+ *
15+ * Unless required by applicable law or agreed to in writing, software
16+ * distributed under the License is distributed on an "AS IS" BASIS,
17+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+ * See the License for the specific language governing permissions and
19+ * limitations under the License.
20+ */
21+
22+#include "hilog-helper.h"
23+#include <stdarg.h>
24+#include "hilog/log_c.h"
25+#include "string.h"
26+
27+void hilogPrint(int level, const char *message)
28+{
29+    if (strchr(message, '.') || strchr(message, '/')) {
30+        HiLogPrint(LOG_CORE, LOG_INFO, 0xD001C00, "cupslog", "%{private}s", message);
31+    } else {
32+        HiLogPrint(LOG_CORE, LOG_INFO, 0xD001C00, "cupslog", "%{public}s", message);
33+    }
34+}
35+
36diff --git a/scheduler/hilog-helper.h b/scheduler/hilog-helper.h
37new file mode 100644
38index 0000000..7baa470
39--- /dev/null
40+++ b/scheduler/hilog-helper.h
41@@ -0,0 +1,16 @@
42+/*
43+ * Copyright (c) 2024 Huawei Device Co., Ltd.
44+ * Licensed under the Apache License, Version 2.0 (the "License");
45+ * you may not use this file except in compliance with the License.
46+ * You may obtain a copy of the License at
47+ *
48+ *     http://www.apache.org/licenses/LICENSE-2.0
49+ *
50+ * Unless required by applicable law or agreed to in writing, software
51+ * distributed under the License is distributed on an "AS IS" BASIS,
52+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53+ * See the License for the specific language governing permissions and
54+ * limitations under the License.
55+ */
56+
57+void hilogPrint(int level, const char *message);
58\ No newline at end of file
59diff --git a/scheduler/log.c b/scheduler/log.c
60index 0fe7f3a..6eb66fe 100644
61--- a/scheduler/log.c
62+++ b/scheduler/log.c
63@@ -22,7 +22,7 @@
64 #  include <systemd/sd-journal.h>
65 #endif /* HAVE_ASL_H */
66 #include <syslog.h>
67-
68+#include "hilog-helper.h"
69
70 /*
71  * Constants for log keys from PWG 5110.3 (PWG Common Log Format)...
72@@ -1267,7 +1267,7 @@ cupsdWriteErrorLog(int        level,	/* I - Log level */
73    /*
74     * Write the log message...
75     */
76-
77+    hilogPrint(level, message);
78     cupsFilePrintf(ErrorFile, "%c %s %s\n", levels[level],
79                    cupsdGetDateTime(NULL, LogTimeFormat), message);
80     cupsFileFlush(ErrorFile);
81