logn

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2019 License: MIT Imports: 9 Imported by: 6

README

logn

A wrap of zap, maybe a simplified log4j for golang.

Installation

go get -u github.com/shanexu/logn

Quick Start

Logn loads configuration file from system environment virable LOGN_CONFIG. If the variable is unset, then Logn will try to load the configuration file from current work directory, the file name is "logn.yaml" or "logn.yml".

appenders:
  console:
    - name: CONSOLE
      target: stdout
      encoder:
        console:
          time_encoder: ISO8601
  file:
    - name: FILE
      file_name: /tmp/app.log
      encoder:
        json:
  gelf_udp:
    - name: GRAYLOG
      host: 127.0.0.1
      port: 12201
      compression_type: none
      encoder:
        gelf:
          key_value_pairs:
            - key: env
              value: ${ENV:dev}
            - key: app
              value: ${APPNAME:demo}
            - key: file
              value: app.log
  rolling_file:
    - name: GELF_FILE
      file_name: /tmp/app_gelf.log
      max_size: 100
      encoder:
        gelf:
          key_value_pairs:
            - key: env
              value: ${ENV:dev}
            - key: app
              value: ${APPNAME:demo}
            - key: file
              value: app.log
loggers:
  root:
    level: info
    appender_refs:
      - CONSOLE
  logger:
    - name: helloworld
      appender_refs:
        - CONSOLE
        - FILE
        - GELF_FILE
        - GRAYLOG
      level: debug      

sample code:

package main

import "github.com/shanexu/logn"

func main() {
	helloWorld := logn.GetLogger("helloworld")
	helloWorld.Info("hello, shane!")

	some := logn.GetLogger("some")
	some.Infof("hello, %s", "shane")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(name string) core.Logger

func Sync

func Sync()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL