logging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2013 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2013, Cong Ding. All rights reserved.

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

http://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.

author: Cong Ding <dinggnu@gmail.com>

Copyright 2013, Cong Ding. All rights reserved.

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

http://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.

author: Cong Ding <dinggnu@gmail.com>

Copyright 2013, Cong Ding. All rights reserved.

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

http://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.

author: Cong Ding <dinggnu@gmail.com>

Copyright 2013, Cong Ding. All rights reserved.

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

http://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.

author: Cong Ding <dinggnu@gmail.com>

Package logging implements log library for other applications. It provides functions Debug, Info, Warning, Error, Critical, and formatting version Logf.

Example:

logger := logging.SimpleLogger("main")
logger.SetLevel(logging.WARNING)
logger.Error("test for error")
logger.Warning("test for warning", "second parameter")
logger.Debug("test for debug")

Copyright 2013, Cong Ding. All rights reserved.

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

http://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.

author: Cong Ding <dinggnu@gmail.com>

Copyright 2013, Cong Ding. All rights reserved.

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

http://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.

author: Cong Ding <dinggnu@gmail.com>

Index

Constants

View Source
const (
	BasicFormat = "%s [%6s] %30s - %s\n name,levelname,time,message"
	RichFormat  = "%s [%6s] %d %30s - %d - %s:%s:%d - %s\n name, levelname, seqid, time, thread, filename, funcname, lineno, message"
)

pre-defined formats

View Source
const (
	DefaultFileName   = "logging.log"                   // default logging filename
	DefaultConfigFile = "logging.conf"                  // default logging configuration file
	DefaultTimeFormat = "2006-01-02 15:04:05.999999999" // defaulttime format

)

Pre-defined formats

Variables

This section is empty.

Functions

func GetGoID

func GetGoID() int32

GetGoID returns the id of goroutine, which is defined in ./get_go_id.c

func GetLevelName

func GetLevelName(levelValue Level) string

GetLevelName lets users be able to get level name from level value.

Types

type Level

type Level int32

Level is the type of level.

const (
	CRITICAL Level = 50
	FATAL    Level = CRITICAL
	ERROR    Level = 40
	WARNING  Level = 30
	WARN     Level = WARNING
	INFO     Level = 20
	DEBUG    Level = 10
	NOTSET   Level = 0
)

Values of level

func GetLevelValue

func GetLevelValue(levelName string) Level

GetLevelValue lets users be able to get level value from level name.

func (*Level) String

func (level *Level) String() string

String function casts level value to string

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is the logging struct.

func BasicLogger

func BasicLogger(name string) (*Logger, error)

BasicLogger creates a new logger with basic configuration.

func ConfigLogger

func ConfigLogger(filename string) (*Logger, error)

WriterLogger creates a new logger from a configuration file

func FileLogger

func FileLogger(name string, level Level, format string, timeFormat string, file string, sync bool) (*Logger, error)

FileLogger creates a new logger with file output.

func RichLogger

func RichLogger(name string) (*Logger, error)

RichLogger creates a new logger with simple configuration.

func SimpleLogger

func SimpleLogger(name string) (*Logger, error)

SimpleLogger creates a new logger with simple configuration.

func WriterLogger

func WriterLogger(name string, level Level, format string, timeFormat string, out io.Writer, sync bool) (*Logger, error)

WriterLogger creates a new logger with a writer

func (*Logger) Critical

func (logger *Logger) Critical(v ...interface{})

func (*Logger) Criticalf

func (logger *Logger) Criticalf(format string, v ...interface{})

func (*Logger) Debug

func (logger *Logger) Debug(v ...interface{})

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, v ...interface{})

func (*Logger) Destroy

func (logger *Logger) Destroy()

Destroy sends quit signal to watcher and releases all the resources.

func (*Logger) Error

func (logger *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, v ...interface{})

func (*Logger) Fatal

func (logger *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, v ...interface{})

func (*Logger) Flush

func (logger *Logger) Flush()

Flush the writer

func (*Logger) Info

func (logger *Logger) Info(v ...interface{})

func (*Logger) Infof

func (logger *Logger) Infof(format string, v ...interface{})

func (*Logger) Level

func (logger *Logger) Level() Level

func (*Logger) Log

func (logger *Logger) Log(level Level, v ...interface{})

Logln receives log request from the client. The request includes a set of variables.

func (*Logger) Logf

func (logger *Logger) Logf(level Level, format string, v ...interface{})

Logf receives log request from the client. The request has a string parameter to describe the format of output.

func (*Logger) Name

func (logger *Logger) Name() string

func (*Logger) Notset

func (logger *Logger) Notset(v ...interface{})

func (*Logger) Notsetf

func (logger *Logger) Notsetf(format string, v ...interface{})

func (*Logger) RecordArgs

func (logger *Logger) RecordArgs() []string

func (*Logger) RecordFormat

func (logger *Logger) RecordFormat() string

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level Level)

func (*Logger) SetWriter

func (logger *Logger) SetWriter(out ...io.Writer)

func (*Logger) StartTime

func (logger *Logger) StartTime() int64

func (*Logger) Sync

func (logger *Logger) Sync() bool

func (*Logger) TimeFormat

func (logger *Logger) TimeFormat() string

func (*Logger) Warn

func (logger *Logger) Warn(v ...interface{})

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, v ...interface{})

func (*Logger) Warning

func (logger *Logger) Warning(v ...interface{})

func (*Logger) Warningf

func (logger *Logger) Warningf(format string, v ...interface{})

func (*Logger) Writer

func (logger *Logger) Writer() io.Writer

Jump to

Keyboard shortcuts

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