文件最后提交记录最后更新时间
Logger升级Stage模型 Signed-off-by: Administrator <zhuxun9@huawei.com> 3 年前
修复Logger流水线报错问题 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
Socket、WebSocket、Canvas、CustomCommonEvent、Logger ohpm迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
修复Logger流水线报错问题 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
Logger升级Stage模型 Signed-off-by: Administrator <zhuxun9@huawei.com> 3 年前
!2255 【0230】code目录下代码适配 part.1+2+3 * code目录下代码适配 part.3 * code目录下代码适配 part.2 * code目录下代码适配 part.1 Signed-off-by: sunwenxu <sunwenxu1@huawei.com> 3 年前
revert sdk version 10->9 Signed-off-by: sunwenxu <sunwenxu1@huawei.com> 3 年前
Logger、FileBackExtension、FileManager、Picker、SandboxShare Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
revert sdk version 10->9 Signed-off-by: sunwenxu <sunwenxu1@huawei.com> 3 年前
Logger升级Stage模型 Signed-off-by: Administrator <zhuxun9@huawei.com> 3 年前
Socket、WebSocket、Canvas、CustomCommonEvent、Logger ohpm迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
Socket、WebSocket、Canvas、CustomCommonEvent、Logger ohpm迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
Socket、WebSocket、Canvas、CustomCommonEvent、Logger ohpm迁移 Signed-off-by: yeyedeshen <yangxin181@huawei.com> 2 年前
添加测试用例 Signed-off-by: @two-thousand-or-three-thousand <lisiquan1@huawei.com> 3 年前
README.md

Log

Introduction

This sample shows how to use log APIs to print log information and save the information to the application installation directory.

APIs

    import logger from '@ohos/log'
    import { LogLevel } from '@ohos/log'
    import { Configure }  from '@ohos/log'

Usage Instruction

  1. Configure log printing parameters.
  Configure = {
    cheese: {
        types: string[],
        filename: string
    }
    defaults: {
        appenders: string,
        level: LogLevel
    }
  } 
  // If types is set to file, logs are saved to the file named by filename. appenders indicates the log tag, and level indicates the lowest log level.
  1. Initialize a logger instance.
   logger.setConfigure(configure: Configure)
   // configure indicates the parameter configuration.
  1. Print log information of the debug level.
   logger.debug(value) 
   // value indicates the log content.
  1. Print log information of the info level.
   logger.info(value) 
   // value indicates the log content.
  1. Print log information of the warn level.
   logger.warn(value) 
   // value indicates the log content.
  1. Print log information of the error level.
   logger.error(value) 
   // value indicates the log content.
  1. Print log information of the fatal level.
   logger.fatal(value, bool) 
   // value indicates the log content.

Constraints

  1. This sample requires API version 9 or later.

  2. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run.