Skip to content

Latest commit

 

History

History
51 lines (44 loc) · 1.29 KB

README.md

File metadata and controls

51 lines (44 loc) · 1.29 KB

simple-logging

One file simple logging utility. Fledged console logging without dependency.

How to use:

Just copy file content, add your package name and private modifier, you're good to go.

Basic usage:

class MyClass extends SimpleLogging{
  trace(...)
  debug(...)
  info(...) //default logging level.
  warn(...)
  error(...)
}

Change logging level:

  1. override loggerLevel
class MyClass extends SimpleLogging{
  override val loggerLevel = SimpleLogging.Trace
}
  1. provide property file: simple-logger.properties in resources dir.
com.github.cuzfrog.scmd = info
com.github.cuzfrog.scmd.runtime = debug
com.github.cuzfrog.scmd.runtime.SomeObject$ = trace

Change logger name:

class MyClass extends SimpleLogging{
  override lazy val loggerAgent = classOf[WhatEver].getName
}

AOP logging:

A scalameta annotation is shipped for control single AOP method:

@IgnoreLogging
abstract override def addValidation[T](name: String, func: (T) => Unit): Unit = {
  debug(s"Add validation for arg:$name, func:$func")
  super.addValidation(name, func)
}

Aop Code example: portal

@IgnoreLogging depends on ScalaMeta at compile time.