1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/harmonyos_samples-logger

Клонировать/Скачать
Внести вклад в разработку кода
Синхронизировать код
Отмена
Подсказка: Поскольку Git не поддерживает пустые директории, создание директории приведёт к созданию пустого файла .keep.
Loading...
README.en.md

Printing Logs

Overview

This sample shows how to use the loggers of the HiLog system so that your app or service can output logs based on the specified level, ID, and string format, helping you understand the running status of your app or service and better debug it.

Preview

Home page
image

Instructions:

  1. Access the application and an empty log file is automatically generated.

  2. Click the log button to export logs to a log file.

Project Directory

├──entry/src/main/ets/
│  └──pages
│     └──Index.ets                          // Home page
└──log/src/main/ets/
   └──components
      └──mainpage
         ├──Configure.ets                   // Configuration items of the logger
         ├──Logger.ets                      // Logger
         ├──LoggerModel.ts                  // Encapsulation of the logger
         └──LogLevel.ts                     // Enums of the log level

How to Implement

  • The log output function is encapsulated in the Logger. For details about the source code, see Logger.ets.
    • Output logs. The Logger class classifies logs into three types based on the types parameter of Configure. For the file type, logs are written into local files. For the console type, logs are output by calling the ConsoleLoggerStrategy class. For the hilog type, logs are output by calling the HilogLoggerStrategy class.
    • Write log files to the local host. The FileLoggerStrategy class uses @ohos.file.fs to write logs to a local file. This sample only shows how to write logs to a file. In practice, you are advised to run time-consuming operations in subthreads.

Required Permissions

N/A

Dependency

N/A

Constraints

  1. The sample is supported only on Huawei phones with standard systems.

  2. The HarmonyOS version must be HarmonyOS 5.0.0 Release or later.

  3. The DevEco Studio version must be DevEco Studio 5.0.0 Release or later.

  4. The HarmonyOS SDK version must be HarmonyOS 5.0.0 Release SDK or later.

Комментарии ( 0 )

Вы можете оставить комментарий после Вход в систему

Введение

Этот пример использует систему логирования hilog, которая предоставляет классы для вывода логов, позволяя приложению/сервису выводить содержимое логов по заданному уровню, идентификатору и строке формата. Это помогает разработчикам понимать состояние работы приложения/сервиса и лучше отлаживать программу. Развернуть Свернуть
Apache-2.0
Отмена

Обновления

Пока нет обновлений

Участники

все

Язык

Недавние действия

Загрузить больше
Больше нет результатов для загрузки
1
https://api.gitlife.ru/oschina-mirror/harmonyos_samples-logger.git
git@api.gitlife.ru:oschina-mirror/harmonyos_samples-logger.git
oschina-mirror
harmonyos_samples-logger
harmonyos_samples-logger
master