Skip to content

HarborZeng/gangsutils

Repository files navigation

gangsutils

Goal Badges
Packages andReleases Maven Central Sonatype Nexus
JavaDocumentation javadoc
BuildStatus develop build master build
JaCoCo TestCoverage codecov
License License FOSSA Status

Utilities

Gangsutils stands for Gang Scala Utils, it includes several modules.

Replace ${gangsutils.version} to the latest stable version showed in the nexus repository badge Sonatype Nexus

Note: Only import what you need to avoid unnecessary download.

Maven

<dependency>
    <groupId>cn.tellyouwhat</groupId>
    <artifactId>gangsutils-logger</artifactId>
    <version>${gangsutils.version}</version>
</dependency>
<dependency>
    <groupId>cn.tellyouwhat</groupId>
    <artifactId>gangsutils-spark</artifactId>
    <version>${gangsutils.version}</version>
</dependency>
<dependency>
    <groupId>cn.tellyouwhat</groupId>
    <artifactId>gangsutils-hadoop</artifactId>
    <version>${gangsutils.version}</version>
</dependency>
<dependency>
    <groupId>cn.tellyouwhat</groupId>
    <artifactId>gangsutils-core</artifactId>
    <version>${gangsutils.version}</version>
</dependency>

or import all by

<dependency>
    <groupId>cn.tellyouwhat</groupId>
    <artifactId>gangsutils-all</artifactId>
    <version>${gangsutils.version}</version>
</dependency>

SBT

libraryDependencies += "cn.tellyouwhat" % "gangsutils-logger" % "${gangsutils.version}"
libraryDependencies += "cn.tellyouwhat" % "gangsutils-spark" % "${gangsutils.version}"
libraryDependencies += "cn.tellyouwhat" % "gangsutils-hadoop" % "${gangsutils.version}"
libraryDependencies += "cn.tellyouwhat" % "gangsutils-core" % "${gangsutils.version}"

or import all by

libraryDependencies += "cn.tellyouwhat" % "gangsutils-all" % "${gangsutils.version}"

Gradle

implementation 'cn.tellyouwhat:gangsutils-logger:${gangsutils.version}'
implementation 'cn.tellyouwhat:gangsutils-spark:${gangsutils.version}'
implementation 'cn.tellyouwhat:gangsutils-hadoop:${gangsutils.version}'
implementation 'cn.tellyouwhat:gangsutils-core:${gangsutils.version}'

or import all by

implementation 'cn.tellyouwhat:gangsutils-all:${gangsutils.version}'

logger

see gangsutils-logger 使用指南.md

functions and helpers

If you just want functions and helpers which do not involve spark and hadoop, add only gangsutils-core dependency.

constants

There are a lot of strings, used to build log content and test.

functions

These functions could be useful in you are coding in Scala, see https://github.com/HarborZeng/gangsutils/blob/master/gangsutils-core/src/test/scala/cn/tellyouwhat/gangsutils/core/funcsTest.scala test case for use case.

helpers

There are a few helpers, like ConfigReader, I18N(internal use only) and chaining.

chaining is a good implicit object that can help you write scala code with less vals and vars.

It implements tap and pipe like in unix terminal system.

You can refer to https://alvinalexander.com/scala/scala-2.13-pipe-tap-chaining-operations/ for example.

PS: Implementation in chaining is |! for tap and |> for pipe

eg,

https://github.com/HarborZeng/gangsutils/blob/master/gangsutils-core/src/main/scala/cn/tellyouwhat/gangsutils/core/helper/chaining.scala

spark functions

If you just want functions and helpers which is spark related, add only gangsutils-spark dependency.

Spark function.

see https://github.com/HarborZeng/gangsutils/blob/master/gangsutils-spark/src/test/scala/cn/tellyouwhat/gangsutils/spark/funcsTest.scala for use cases.

TODO

  • Make I18N private in gangsutils
  • Change gangConfig.properties file name to gangsutilsConfig.properties
  • Use yaml instead of properties file for configuration
  • Use system default language and region when gangsutilsConfig.properties is overwritten but default-lang or default-region are missing
  • Change sendRequest parameter queryStrings to form
  • Extract .replaceAll("""\e\[[\d;]*[^\d;]""", "") to a method stripANSIColor
  • Change Logger defaultLogDest to PRINTLN_LOGGER to test whether enabled parameter works when logger is got by GangLogger.getLogger
  • Separate spark and hadoop tools into separate modules
  • Extract logger module from common module
  • Add FileLogger (by date)
  • Add LogStash(Stream)Logger
  • Make hostname lazy
  • Make log a case class containing hostname, datetime, trace, content and etc, serialize it when using(println or send to webhook)
  • Different log configurations for different logs by default value and config file
  • Add proxy settings for TelegramWebhookLogger
  • .replace("\n", "\\n")
  • async log
  • static members setup for each logger individually
  • stacktrace

License

FOSSA Status