pklog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

README

go-pklog

go-pklog providing log files on syslog and live on stdout written in Golang. This package is written in Golang. This logging package is able to generate two types of log information both on:

  • syslog
  • stdout

Badges

golang version

Author

Pezhman Kasraee pezhmankasraee@gmail.com.

Download the package

go get -u github.com/pezhmankasraee/go-pklog

Example

Before starting the application, you shoud set the environmental variable PKLOG. If the application is going to be run on development mode, you should set it as follows:

export PKLOG="DEVELOPMENT"

or if the application is going to be run on server, the environment variable should be set as follows:

export PKLOG="PRODUCTION"

Then you should write your code as follows:

package main

import "github.com/pezhmankasraee/go-pklog"

func main() {
	pklog.CreateLog(pklog.Error, "Hello, Error")
}

if you run the application with PKLOG="DEVELOPMENT", you will see the result on stdout, or if you run it with PKLOG="PRODUCTION" the result will be reflected on /var/log/syslog. You can see the result by:

$ cat /var/log/syslog

Documentation

Index

Constants

View Source
const (
	FatalError  int = 0
	Error       int = 100
	Warning     int = 200
	Information int = 300
)

Log level defines the severity of log report. FatalError prints out a message and also causes os.Exit(1). Error, Warning and Info prints out only a message.

Variables

This section is empty.

Functions

func CreateLog

func CreateLog(logLevel int, s string)

CreateLog prints out a log message depends on application life cycle. This module reads first the result of environment parameter REST_APP. If PKLOG is equal to "PRODUCTION", the logs will be generated in /var/log/syslog otherwise the logs will be displayed with color on standard display. logLevel accepts four types of log level: FatalError(0), Error (10), Warning (20) and Info (30). s is the log message which is of type string.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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