Browse Source

init commit

yanyi 3 years ago
commit
793e8ecc64
39 changed files with 1218 additions and 0 deletions
  1. 105 0
      .gitignore
  2. 3 0
      .idea/.gitignore
  3. 6 0
      .idea/compiler.xml
  4. 30 0
      .idea/jarRepositories.xml
  5. 4 0
      .idea/misc.xml
  6. 38 0
      build.gradle
  7. 1 0
      entry/.gitignore
  8. 27 0
      entry/build.gradle
  9. 1 0
      entry/proguard-rules.pro
  10. 46 0
      entry/src/main/config.json
  11. 13 0
      entry/src/main/java/com/mylove/logger/MainAbility.java
  12. 10 0
      entry/src/main/java/com/mylove/logger/MyApplication.java
  13. 23 0
      entry/src/main/java/com/mylove/logger/slice/MainAbilitySlice.java
  14. 16 0
      entry/src/main/resources/base/element/string.json
  15. 6 0
      entry/src/main/resources/base/graphic/background_ability_main.xml
  16. 19 0
      entry/src/main/resources/base/layout/ability_main.xml
  17. BIN
      entry/src/main/resources/base/media/icon.png
  18. 16 0
      entry/src/main/resources/en/element/string.json
  19. 16 0
      entry/src/main/resources/zh/element/string.json
  20. 14 0
      entry/src/ohosTest/java/com/mylove/logger/ExampleOhosTest.java
  21. 9 0
      entry/src/test/java/com/mylove/logger/ExampleTest.java
  22. 13 0
      gradle.properties
  23. BIN
      gradle/wrapper/gradle-wrapper.jar
  24. 5 0
      gradle/wrapper/gradle-wrapper.properties
  25. 183 0
      gradlew
  26. 103 0
      gradlew.bat
  27. 1 0
      loglib/.gitignore
  28. 22 0
      loglib/build.gradle
  29. 1 0
      loglib/consumer-rules.pro
  30. 1 0
      loglib/proguard-rules.pro
  31. 27 0
      loglib/src/main/config.json
  32. 57 0
      loglib/src/main/java/com/benyanyi/loglib/BaseLog.java
  33. 309 0
      loglib/src/main/java/com/benyanyi/loglib/Jlog.java
  34. 41 0
      loglib/src/main/java/com/benyanyi/loglib/JsonLog.java
  35. 25 0
      loglib/src/main/java/com/benyanyi/loglib/LogUtil.java
  36. 9 0
      loglib/src/main/java/com/benyanyi/loglib/TextUtils.java
  37. 8 0
      loglib/src/main/resources/base/element/string.json
  38. 9 0
      loglib/src/test/java/com/benyanyi/loglib/ExampleTest.java
  39. 1 0
      settings.gradle

+ 105 - 0
.gitignore

@@ -0,0 +1,105 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+/entry/.preview
+.cxx
+### Android template
+# Built application files
+*.apk
+*.aar
+*.ap_
+*.aab
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+#  Uncomment the following line in case you need and you don't have the release build type files in your app
+# release/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# IntelliJ
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/assetWizardSettings.xml
+.idea/dictionaries
+.idea/libraries
+# Android Studio 3 in .gitignore file.
+.idea/caches
+.idea/modules.xml
+# Comment next line if keeping position of elements in Navigation Editor is relevant for you
+.idea/navEditor.xml
+
+# Keystore files
+# Uncomment the following lines if you do not want to check your keystore files in.
+#*.jks
+#*.keystore
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+.cxx/
+
+# Google Services (e.g. APIs or Firebase)
+# google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
+# fastlane
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md
+
+# Version control
+vcs.xml
+
+# lint
+lint/intermediates/
+lint/generated/
+lint/outputs/
+lint/tmp/
+# lint/reports/
+
+# Android Profiling
+*.hprof
+

+ 3 - 0
.idea/.gitignore

@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml

+ 6 - 0
.idea/compiler.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <bytecodeTargetLevel target="1.8" />
+  </component>
+</project>

+ 30 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven2" />
+      <option name="name" value="maven2" />
+      <option name="url" value="https://developer.huawei.com/repo/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="BintrayJCenter" />
+      <option name="name" value="BintrayJCenter" />
+      <option name="url" value="https://jcenter.bintray.com/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven" />
+      <option name="name" value="maven" />
+      <option name="url" value="https://repo.huaweicloud.com/repository/maven/" />
+    </remote-repository>
+  </component>
+</project>

+ 4 - 0
.idea/misc.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
+</project>

+ 38 - 0
build.gradle

@@ -0,0 +1,38 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510
+ohos {
+    compileSdkVersion 5
+    defaultConfig {
+        compatibleSdkVersion 4
+    }
+}
+	
+buildscript {
+    repositories {
+        maven {
+            url 'https://repo.huaweicloud.com/repository/maven/'
+        }
+        maven {
+            url 'https://developer.huawei.com/repo/'
+        }
+		jcenter()
+    }
+    dependencies {
+        classpath 'com.huawei.ohos:hap:2.4.4.2'
+        classpath 'com.huawei.ohos:decctest:1.2.4.0'
+    }
+}
+
+allprojects {
+    repositories {
+        maven {
+            url 'https://repo.huaweicloud.com/repository/maven/'
+        }
+        maven {
+            url 'https://developer.huawei.com/repo/'
+        }
+		jcenter()
+    }
+}

+ 1 - 0
entry/.gitignore

@@ -0,0 +1 @@
+/build

+ 27 - 0
entry/build.gradle

@@ -0,0 +1,27 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510
+ohos {
+    compileSdkVersion 5
+    defaultConfig {
+        compatibleSdkVersion 4
+    }
+    buildTypes {
+        release {
+            proguardOpt {
+                proguardEnabled false
+                rulesFiles 'proguard-rules.pro'
+            }
+        }
+    }
+    
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+    testImplementation 'junit:junit:4.13'
+    ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+}
+decc {
+    supportType = ['html','xml']
+}

+ 1 - 0
entry/proguard-rules.pro

@@ -0,0 +1 @@
+# config module specific ProGuard rules here.

+ 46 - 0
entry/src/main/config.json

@@ -0,0 +1,46 @@
+{
+  "app": {
+    "bundleName": "com.mylove.logger",
+    "vendor": "mylove",
+    "version": {
+      "code": 1000000,
+      "name": "1.0.0"
+    }
+  },
+  "deviceConfig": {},
+  "module": {
+    "package": "com.mylove.logger",
+    "name": ".MyApplication",
+    "mainAbility": "com.mylove.logger.MainAbility",
+    "deviceType": [
+      "phone"
+    ],
+    "distro": {
+      "deliveryWithInstall": true,
+      "moduleName": "entry",
+      "moduleType": "entry",
+      "installationFree": false
+    },
+    "abilities": [
+      {
+        "skills": [
+          {
+            "entities": [
+              "entity.system.home"
+            ],
+            "actions": [
+              "action.system.home"
+            ]
+          }
+        ],
+        "orientation": "unspecified",
+        "name": "com.mylove.logger.MainAbility",
+        "icon": "$media:icon",
+        "description": "$string:mainability_description",
+        "label": "$string:entry_MainAbility",
+        "type": "page",
+        "launchType": "standard"
+      }
+    ]
+  }
+}

+ 13 - 0
entry/src/main/java/com/mylove/logger/MainAbility.java

@@ -0,0 +1,13 @@
+package com.mylove.logger;
+
+import com.mylove.logger.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+public class MainAbility extends Ability {
+    @Override
+    public void onStart(Intent intent) {
+        super.onStart(intent);
+        super.setMainRoute(MainAbilitySlice.class.getName());
+    }
+}

+ 10 - 0
entry/src/main/java/com/mylove/logger/MyApplication.java

@@ -0,0 +1,10 @@
+package com.mylove.logger;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+public class MyApplication extends AbilityPackage {
+    @Override
+    public void onInitialize() {
+        super.onInitialize();
+    }
+}

+ 23 - 0
entry/src/main/java/com/mylove/logger/slice/MainAbilitySlice.java

@@ -0,0 +1,23 @@
+package com.mylove.logger.slice;
+
+import com.mylove.logger.ResourceTable;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+
+public class MainAbilitySlice extends AbilitySlice {
+    @Override
+    public void onStart(Intent intent) {
+        super.onStart(intent);
+        super.setUIContent(ResourceTable.Layout_ability_main);
+    }
+
+    @Override
+    public void onActive() {
+        super.onActive();
+    }
+
+    @Override
+    public void onForeground(Intent intent) {
+        super.onForeground(intent);
+    }
+}

+ 16 - 0
entry/src/main/resources/base/element/string.json

@@ -0,0 +1,16 @@
+{
+  "string": [
+    {
+      "name": "entry_MainAbility",
+      "value": "entry_MainAbility"
+    },
+    {
+      "name": "mainability_description",
+      "value": "Java_Empty Ability"
+    },
+    {
+      "name": "mainability_HelloWorld",
+      "value": "Hello World"
+    }
+  ]
+}

+ 6 - 0
entry/src/main/resources/base/graphic/background_ability_main.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
+       ohos:shape="rectangle">
+    <solid
+        ohos:color="#FFFFFF"/>
+</shape>

+ 19 - 0
entry/src/main/resources/base/layout/ability_main.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<DirectionalLayout
+    xmlns:ohos="http://schemas.huawei.com/res/ohos"
+    ohos:alignment="center"
+    ohos:height="match_parent"
+    ohos:orientation="vertical"
+    ohos:width="match_parent">
+
+    <Text
+        ohos:background_element="$graphic:background_ability_main"
+        ohos:height="match_content"
+        ohos:id="$+id:text_helloworld"
+        ohos:layout_alignment="horizontal_center"
+        ohos:text="$string:mainability_HelloWorld"
+        ohos:text_size="40vp"
+        ohos:width="match_content"
+        />
+
+</DirectionalLayout>

BIN
entry/src/main/resources/base/media/icon.png


+ 16 - 0
entry/src/main/resources/en/element/string.json

@@ -0,0 +1,16 @@
+{
+  "string": [
+    {
+      "name": "entry_MainAbility",
+      "value": "entry_MainAbility"
+    },
+    {
+      "name": "mainability_description",
+      "value": "Java_Empty Ability"
+    },
+    {
+      "name": "mainability_HelloWorld",
+      "value": "Hello World"
+    }
+  ]
+}

+ 16 - 0
entry/src/main/resources/zh/element/string.json

@@ -0,0 +1,16 @@
+{
+  "string": [
+    {
+      "name": "entry_MainAbility",
+      "value": "entry_MainAbility"
+    },
+    {
+      "name": "mainability_description",
+      "value": "Java_Empty Ability"
+    },
+    {
+      "name": "mainability_HelloWorld",
+      "value": "你好,世界"
+    }
+  ]
+}

+ 14 - 0
entry/src/ohosTest/java/com/mylove/logger/ExampleOhosTest.java

@@ -0,0 +1,14 @@
+package com.mylove.logger;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+    @Test
+    public void testBundleName() {
+        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+        assertEquals("com.mylove.logger", actualBundleName);
+    }
+}

+ 9 - 0
entry/src/test/java/com/mylove/logger/ExampleTest.java

@@ -0,0 +1,9 @@
+package com.mylove.logger;
+
+import org.junit.Test;
+
+public class ExampleTest {
+    @Test
+    public void onStart() {
+    }
+}

+ 13 - 0
gradle.properties

@@ -0,0 +1,13 @@
+# Project-wide Gradle settings.
+# IDE (e.g. DevEco Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# If the Chinese output is garbled, please configure the following parameter.
+# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
+# more information see https://docs.gradle.org/current/userguide/performance.html
+# org.gradle.parallel=false
+# org.gradle.jvmargs=-Dfile.encoding=GBK

BIN
gradle/wrapper/gradle-wrapper.jar


+ 5 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists

+ 183 - 0
gradlew

@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+#      https://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.
+#
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+  ls=$(ls -ld "$PRG")
+  link=$(expr "$ls" : '.*-> \(.*\)$')
+  if expr "$link" : '/.*' >/dev/null; then
+    PRG="$link"
+  else
+    PRG=$(dirname "$PRG")"/$link"
+  fi
+done
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=$(basename "$0")
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn() {
+  echo "$*"
+}
+
+die() {
+  echo
+  echo "$*"
+  echo
+  exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$(uname)" in
+CYGWIN*)
+  cygwin=true
+  ;;
+Darwin*)
+  darwin=true
+  ;;
+MINGW*)
+  msys=true
+  ;;
+NONSTOP*)
+  nonstop=true
+  ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ]; then
+  if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+    # IBM's JDK on AIX uses strange locations for the executables
+    JAVACMD="$JAVA_HOME/jre/sh/java"
+  else
+    JAVACMD="$JAVA_HOME/bin/java"
+  fi
+  if [ ! -x "$JAVACMD" ]; then
+    die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+  fi
+else
+  JAVACMD="java"
+  which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then
+  MAX_FD_LIMIT=$(ulimit -H -n)
+  if [ $? -eq 0 ]; then
+    if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+      MAX_FD="$MAX_FD_LIMIT"
+    fi
+    ulimit -n $MAX_FD
+    if [ $? -ne 0 ]; then
+      warn "Could not set maximum file descriptor limit: $MAX_FD"
+    fi
+  else
+    warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+  fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+  GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+  APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+  CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+  JAVACMD=$(cygpath --unix "$JAVACMD")
+
+  # We build the pattern for arguments to be converted via cygpath
+  ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
+  SEP=""
+  for dir in $ROOTDIRSRAW; do
+    ROOTDIRS="$ROOTDIRS$SEP$dir"
+    SEP="|"
+  done
+  OURCYGPATTERN="(^($ROOTDIRS))"
+  # Add a user-defined pattern to the cygpath arguments
+  if [ "$GRADLE_CYGPATTERN" != "" ]; then
+    OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+  fi
+  # Now convert the arguments - kludge to limit ourselves to /bin/sh
+  i=0
+  for arg in "$@"; do
+    CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -)
+    CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option
+
+    if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition
+      eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
+    else
+      eval $(echo args$i)="\"$arg\""
+    fi
+    i=$(expr $i + 1)
+  done
+  case $i in
+  0) set -- ;;
+  1) set -- "$args0" ;;
+  2) set -- "$args0" "$args1" ;;
+  3) set -- "$args0" "$args1" "$args2" ;;
+  4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+  5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+  6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+  7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+  8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+  9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+  esac
+fi
+
+# Escape application args
+save() {
+  for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+  echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"

+ 103 - 0
gradlew.bat

@@ -0,0 +1,103 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem      https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 1 - 0
loglib/.gitignore

@@ -0,0 +1 @@
+/build

+ 22 - 0
loglib/build.gradle

@@ -0,0 +1,22 @@
+apply plugin: 'com.huawei.ohos.library'
+//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510
+ohos {
+    compileSdkVersion 5
+    defaultConfig {
+        compatibleSdkVersion 4
+    }
+    buildTypes {
+        release {
+            proguardOpt {
+                proguardEnabled false
+                rulesFiles 'proguard-rules.pro'
+            }
+        }
+    }
+    
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    testImplementation 'junit:junit:4.13'
+}

+ 1 - 0
loglib/consumer-rules.pro

@@ -0,0 +1 @@
+# Add har specific ProGuard rules for consumer here.

+ 1 - 0
loglib/proguard-rules.pro

@@ -0,0 +1 @@
+# config module specific ProGuard rules here.

+ 27 - 0
loglib/src/main/config.json

@@ -0,0 +1,27 @@
+{
+  "app": {
+    "bundleName": "com.mylove.logger",
+    "vendor": "benyanyi",
+    "version": {
+      "code": 1000000,
+      "name": "1.0.0"
+    }
+  },
+  "deviceConfig": {
+  },
+  "module": {
+    "package": "com.benyanyi.loglib",
+    "deviceType": [
+      "phone",
+      "tablet",
+      "tv",
+      "wearable",
+      "car"
+    ],
+    "distro": {
+      "deliveryWithInstall": true,
+      "moduleName": "loglib",
+      "moduleType": "har"
+    }
+  }
+}

+ 57 - 0
loglib/src/main/java/com/benyanyi/loglib/BaseLog.java

@@ -0,0 +1,57 @@
+package com.benyanyi.loglib;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * @author myLove
+ * @time 2017/10/31 10:41
+ * @e-mail mylove.520.y@gmail.com
+ * @overview
+ */
+
+class BaseLog {
+
+    private static final int MAX_LENGTH = 4000;
+
+    static void printDefault(int type, String tag, String msg) {
+
+        int index = 0;
+        int length = msg.length();
+        int countOfSub = length / MAX_LENGTH;
+
+        if (countOfSub > 0) {
+            for (int i = 0; i < countOfSub; i++) {
+                String sub = msg.substring(index, index + MAX_LENGTH);
+                printSub(type, tag, sub);
+                index += MAX_LENGTH;
+            }
+            printSub(type, tag, msg.substring(index, length));
+        } else {
+            printSub(type, tag, msg);
+        }
+    }
+
+    private static void printSub(int type, String tag, String sub) {
+        switch (type) {
+            case Jlog.D:
+                HiLog.debug(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), sub);
+                break;
+            case Jlog.I:
+                HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), sub);
+                break;
+            case Jlog.W:
+                HiLog.warn(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), sub);
+                break;
+            case Jlog.E:
+                HiLog.error(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), sub);
+                break;
+            case Jlog.F:
+                HiLog.fatal(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), sub);
+                break;
+            default:
+                HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), sub);
+                break;
+        }
+    }
+}

+ 309 - 0
loglib/src/main/java/com/benyanyi/loglib/Jlog.java

@@ -0,0 +1,309 @@
+package com.benyanyi.loglib;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public final class Jlog {
+    static final String LINE_SEPARATOR = System.getProperty("line.separator");
+    static final String NULL_TIPS = "Log with null object";
+
+    private static final String DEFAULT_MESSAGE = "********";
+    private static final String PARAM = "Param";
+    private static final String NULL = "null";
+    private static final String TAG_DEFAULT = "Jlog";
+    private static String SUFFIX = ".java";
+
+    static final int JSON_INDENT = 4;
+
+    static final int D = 0x1;
+    static final int I = 0x2;
+    static final int W = 0x3;
+    static final int E = 0x4;
+    static final int F = 0x5;
+
+    private static final int JSON = 0x7;
+    private static final int XML = 0x8;
+
+    private static final int STACK_TRACE_INDEX_5 = 5;
+    private static final int STACK_TRACE_INDEX_4 = 4;
+
+    private static String mGlobalTag;
+    private static boolean mIsGlobalTagEmpty = true;
+    private static boolean IS_SHOW_LOG = true;
+    private static boolean IS_INIT = false;
+
+    public static void init(boolean isShowLog) {
+        IS_SHOW_LOG = isShowLog;
+        IS_INIT = true;
+    }
+
+    public static void init(boolean isShowLog, String tag) {
+        IS_SHOW_LOG = isShowLog;
+        mGlobalTag = tag;
+        mIsGlobalTagEmpty = TextUtils.isEmpty(mGlobalTag);
+        IS_INIT = true;
+    }
+
+    public static void f() {
+        printLog(F, null, DEFAULT_MESSAGE);
+    }
+
+    public static void f(Object msg) {
+        printLog(F, null, msg);
+    }
+
+    public static void f(Object tag, Object... objects) {
+        printLog(F, tag, objects);
+    }
+
+    public static void d() {
+        printLog(D, null, DEFAULT_MESSAGE);
+    }
+
+    public static void d(Object msg) {
+        printLog(D, null, msg);
+    }
+
+    public static void d(Object tag, Object... objects) {
+        printLog(D, tag, objects);
+    }
+
+    public static void i() {
+        printLog(I, null, DEFAULT_MESSAGE);
+    }
+
+    public static void i(Object msg) {
+        printLog(I, null, msg);
+    }
+
+    public static void i(Object tag, Object... objects) {
+        printLog(I, tag, objects);
+    }
+
+    public static void w() {
+        printLog(W, null, DEFAULT_MESSAGE);
+    }
+
+    public static void w(Object msg) {
+        printLog(W, null, msg);
+    }
+
+    public static void w(Object tag, Object... objects) {
+        printLog(W, tag, objects);
+    }
+
+    public static void e() {
+        printLog(E, null, DEFAULT_MESSAGE);
+    }
+
+    public static void e(Object msg) {
+        printLog(E, null, msg);
+    }
+
+    public static void e(Object tag, Object... objects) {
+        printLog(E, tag, objects);
+    }
+
+    public static void json(Object jsonFormat) {
+        printLog(JSON, null, jsonFormat);
+    }
+
+    public static void json(Object tag, String jsonFormat) {
+        printLog(JSON, tag, jsonFormat);
+    }
+
+    public static void xml(Object xml) {
+        printLog(XML, null, xml);
+    }
+
+    public static void xml(Object tag, String xml) {
+        printLog(XML, tag, xml);
+    }
+
+    public static void file(File targetDirectory, Object msg) {
+        printFile(null, targetDirectory, null, msg);
+    }
+
+    public static void file(Object tag, File targetDirectory, Object msg) {
+        printFile(tag, targetDirectory, null, msg);
+    }
+
+    public static void file(Object tag, File targetDirectory, String fileName, Object msg) {
+        printFile(tag, targetDirectory, fileName, msg);
+    }
+
+    public static void debug() {
+        printDebug(null, DEFAULT_MESSAGE);
+    }
+
+    public static void debug(Object msg) {
+        printDebug(null, msg);
+    }
+
+    public static void debug(Object tag, Object... objects) {
+        printDebug(tag, objects);
+    }
+
+    public static void trace() {
+        printStackTrace();
+    }
+
+    private static void printStackTrace() {
+
+        if (!IS_SHOW_LOG) {
+            return;
+        }
+        if (!IS_INIT && isApkInDebug()) {
+            return;
+        }
+
+        Throwable tr = new Throwable();
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        tr.printStackTrace(pw);
+        pw.flush();
+        String message = sw.toString();
+
+        String[] traceString = message.split("\\n\\t");
+        StringBuilder sb = new StringBuilder();
+        sb.append("\n");
+        for (String trace : traceString) {
+            if (trace.contains("at Jlog")) {
+                continue;
+            }
+            sb.append(trace).append("\n");
+        }
+        String[] contents = wrapperContent(STACK_TRACE_INDEX_4, null, sb.toString());
+        String tag = contents[0];
+        String msg = contents[1];
+        String headString = contents[2];
+        BaseLog.printDefault(D, tag, headString + msg);
+    }
+
+    private static void printLog(int type, Object tagStr, Object... objects) {
+
+        if (!IS_SHOW_LOG) {
+            return;
+        }
+        if (!IS_INIT && isApkInDebug()) {
+            return;
+        }
+        String[] contents = wrapperContent(STACK_TRACE_INDEX_5, tagStr, objects);
+        String tag = contents[0];
+        String msg = contents[1];
+        String headString = contents[2];
+
+        switch (type) {
+            default:
+            case D:
+            case I:
+            case W:
+            case E:
+            case F:
+                BaseLog.printDefault(type, tag, headString + msg);
+                break;
+            case JSON:
+                JsonLog.printJson(tag, msg, headString);
+                break;
+            case XML:
+//                XmlLog.printXml(tag, msg, headString);
+                break;
+        }
+
+    }
+
+    private static void printDebug(Object tagStr, Object... objects) {
+        String[] contents = wrapperContent(STACK_TRACE_INDEX_5, tagStr, objects);
+        String tag = contents[0];
+        String msg = contents[1];
+        String headString = contents[2];
+        BaseLog.printDefault(D, tag, headString + msg);
+    }
+
+
+    private static void printFile(Object tagStr, File targetDirectory, String fileName, Object objectMsg) {
+
+        if (!IS_SHOW_LOG) {
+            return;
+        }
+        if (!IS_INIT && isApkInDebug()) {
+            return;
+        }
+        String[] contents = wrapperContent(STACK_TRACE_INDEX_5, tagStr, objectMsg);
+        String tag = contents[0];
+        String msg = contents[1];
+        String headString = contents[2];
+
+//        FileLog.printFile(tag, targetDirectory, fileName, headString, msg);
+    }
+
+    private static String[] wrapperContent(int stackTraceIndex, Object tagStr, Object... objects) {
+
+        SUFFIX = ".java";
+
+        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+
+        StackTraceElement targetElement = stackTrace[stackTraceIndex];
+        String className = targetElement.getClassName();
+        String[] classNameInfo = className.split("\\.");
+        if (classNameInfo.length > 0) {
+            className = classNameInfo[classNameInfo.length - 1] + SUFFIX;
+        }
+        String str = "$";
+        if (className.contains(str)) {
+            className = className.split("\\$")[0] + SUFFIX;
+        }
+
+        String methodName = targetElement.getMethodName();
+        int lineNumber = targetElement.getLineNumber();
+
+        if (lineNumber < 0) {
+            lineNumber = 0;
+        }
+
+        String tag = (tagStr == null ? className : tagStr).toString();
+
+        if (mIsGlobalTagEmpty && TextUtils.isEmpty(tag)) {
+            tag = TAG_DEFAULT;
+        } else if (!mIsGlobalTagEmpty) {
+            tag = mGlobalTag;
+        }
+
+        String msg = (objects == null) ? NULL_TIPS : getObjectsString(objects);
+        String headString = "[ (" + className + ":" + lineNumber + ")#" + methodName + " ] ";
+
+        return new String[]{tag, msg, headString};
+    }
+
+    private static String getObjectsString(Object... objects) {
+
+        if (objects.length > 1) {
+            StringBuilder stringBuilder = new StringBuilder();
+            stringBuilder.append("\n");
+            for (int i = 0; i < objects.length; i++) {
+                Object object = objects[i];
+                if (object == null) {
+                    stringBuilder.append(PARAM).append("[").append(i).append("]").append(" = ").append(NULL).append("\n");
+                } else {
+                    stringBuilder.append(PARAM).append("[").append(i).append("]").append(" = ").append(object.toString()).append("\n");
+                }
+            }
+            return stringBuilder.toString();
+        } else {
+            Object object = objects[0];
+            return object == null ? NULL : object.toString();
+        }
+    }
+
+    private static boolean isApkInDebug() {
+//        try {
+//            @SuppressLint("PrivateApi")
+//            Application application = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null, (Object[]) null);
+//            ApplicationInfo info = application.getApplicationInfo();
+//            return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0;
+//        } catch (Exception e) {
+        return false;
+//        }
+    }
+}

+ 41 - 0
loglib/src/main/java/com/benyanyi/loglib/JsonLog.java

@@ -0,0 +1,41 @@
+package com.benyanyi.loglib;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * @author myLove
+ * @time 2017/10/31 10:42
+ * @e-mail mylove.520.y@gmail.com
+ * @overview
+ */
+
+class JsonLog {
+    static void printJson(String tag, String msg, String headString) {
+
+        String message = "";
+        String str1 = "{";
+        String str2 = "[";
+//        try {
+//            if (msg.startsWith(str1)) {
+//                JSONObject jsonObject = new JSONObject(msg);
+//                message = jsonObject.toString(Jlog.JSON_INDENT);
+//            } else if (msg.startsWith(str2)) {
+//                JSONArray jsonArray = new JSONArray(msg);
+//                message = jsonArray.toString(Jlog.JSON_INDENT);
+//            } else {
+//                message = msg;
+//            }
+//        } catch (JSONException e) {
+//            message = msg;
+//        }
+
+        LogUtil.printLine(tag, true);
+        message = headString + Jlog.LINE_SEPARATOR + message;
+        String[] lines = message.split(Jlog.LINE_SEPARATOR);
+        for (String line : lines) {
+            HiLog.debug(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), "║ " + line);
+        }
+        LogUtil.printLine(tag, false);
+    }
+}

+ 25 - 0
loglib/src/main/java/com/benyanyi/loglib/LogUtil.java

@@ -0,0 +1,25 @@
+package com.benyanyi.loglib;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * @author myLove
+ * @time 2017/10/31 10:43
+ * @e-mail mylove.520.y@gmail.com
+ * @overview
+ */
+
+class LogUtil {
+    static boolean isEmpty(String line) {
+        return TextUtils.isEmpty(line) || "\n".equals(line) || "\t".equals(line) || TextUtils.isEmpty(line.trim());
+    }
+
+    static void printLine(String tag, boolean isTop) {
+        if (isTop) {
+            HiLog.debug(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), "╔═══════════════════════════════════════════════════════════════════════════════════════");
+        } else {
+            HiLog.debug(new HiLogLabel(HiLog.LOG_APP, 0x100, tag), "╚═══════════════════════════════════════════════════════════════════════════════════════");
+        }
+    }
+}

+ 9 - 0
loglib/src/main/java/com/benyanyi/loglib/TextUtils.java

@@ -0,0 +1,9 @@
+package com.benyanyi.loglib;
+
+class TextUtils {
+
+    static boolean isEmpty(String str) {
+        return str == null || str.length() == 0;
+    }
+
+}

+ 8 - 0
loglib/src/main/resources/base/element/string.json

@@ -0,0 +1,8 @@
+{
+  "string": [
+    {
+      "name": "loglib_library",
+      "value": "loglib_library"
+    }
+  ]
+}

+ 9 - 0
loglib/src/test/java/com/benyanyi/loglib/ExampleTest.java

@@ -0,0 +1,9 @@
+package com.benyanyi.loglib;
+
+import org.junit.Test;
+
+public class ExampleTest {
+    @Test
+    public void onStart() {
+    }
+}

+ 1 - 0
settings.gradle

@@ -0,0 +1 @@
+include ':entry', ':loglib'