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 +#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 #endif /* HAVE_ASL_H */ #include - +#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);