6 Star 2 Fork 24

OpenHarmony/third_party_cups

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ohos-hilog-print.patch 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
张子明 提交于 2024-11-23 14:48 . add cups log to hilog
diff --git a/scheduler/hilog-helper.c b/scheduler/hilog-helper.c
new file mode 100644
index 0000000..28d986d
--- /dev/null
+++ b/scheduler/hilog-helper.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed 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 "hilog-helper.h"
+#include <stdarg.h>
+#include "hilog/log_c.h"
+#include "string.h"
+
+void hilogPrint(int level, const char *message)
+{
+ if (strchr(message, '.') || strchr(message, '/')) {
+ HiLogPrint(LOG_CORE, LOG_INFO, 0xD001C00, "cupslog", "%{private}s", message);
+ } else {
+ HiLogPrint(LOG_CORE, LOG_INFO, 0xD001C00, "cupslog", "%{public}s", message);
+ }
+}
+
diff --git a/scheduler/hilog-helper.h b/scheduler/hilog-helper.h
new file mode 100644
index 0000000..7baa470
--- /dev/null
+++ b/scheduler/hilog-helper.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed 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.
+ */
+
+void hilogPrint(int level, const char *message);
\ No newline at end of file
diff --git a/scheduler/log.c b/scheduler/log.c
index 0fe7f3a..6eb66fe 100644
--- a/scheduler/log.c
+++ b/scheduler/log.c
@@ -22,7 +22,7 @@
# include <systemd/sd-journal.h>
#endif /* HAVE_ASL_H */
#include <syslog.h>
-
+#include "hilog-helper.h"
/*
* Constants for log keys from PWG 5110.3 (PWG Common Log Format)...
@@ -1267,7 +1267,7 @@ cupsdWriteErrorLog(int level, /* I - Log level */
/*
* Write the log message...
*/
-
+ hilogPrint(level, message);
cupsFilePrintf(ErrorFile, "%c %s %s\n", levels[level],
cupsdGetDateTime(NULL, LogTimeFormat), message);
cupsFileFlush(ErrorFile);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_cups.git
[email protected]:openharmony/third_party_cups.git
openharmony
third_party_cups
third_party_cups
master

搜索帮助