Git Product home page Git Product logo

seelog's Introduction

Seelog

Seelog is a powerful and easy-to-learn logging framework that provides functionality for flexible dispatching, filtering, and formatting log messages. It is natively written in the Go programming language.

Build Status

Features

  • Xml configuring to be able to change logger parameters without recompilation
  • Changing configurations on the fly without app restart
  • Possibility to set different log configurations for different project files and functions
  • Adjustable message formatting
  • Simultaneous log output to multiple streams
  • Choosing logger priority strategy to minimize performance hit
  • Different output writers
    • Console writer
    • File writer
    • Buffered writer (Chunk writer)
    • Rolling log writer (Logging with rotation)
    • SMTP writer
    • Others... (See Wiki)
  • Log message wrappers (JSON, XML, etc.)
  • Global variables and functions for easy usage in standalone apps
  • Functions for flexible usage in libraries

Quick-start

package main

import log "github.com/cihub/seelog"

func main() {
    defer log.Flush()
    log.Info("Hello from Seelog!")
}

Installation

If you don't have the Go development environment installed, visit the Getting Started document and follow the instructions. Once you're ready, execute the following command:

go get -u github.com/cihub/seelog

IMPORTANT: If you are not using the latest release version of Go, check out this wiki page

Documentation

Seelog has github wiki pages, which contain detailed how-tos references: https://github.com/cihub/seelog/wiki

Examples

Seelog examples can be found here: seelog-examples

Issues

Feel free to push issues that could make Seelog better: https://github.com/cihub/seelog/issues

Changelog

  • v2.6 : Config using code and custom formatters
    • Configuration using code in addition to xml (All internal receiver/dispatcher/logger types are now exported).
    • Custom formatters. Check wiki
    • Bugfixes and internal improvements.
  • v2.5 : Interaction with other systems. Part 2: custom receivers
    • Finished custom receivers feature. Check wiki
    • Added 'LoggerFromCustomReceiver'
    • Added 'LoggerFromWriterWithMinLevelAndFormat'
    • Added 'LoggerFromCustomReceiver'
    • Added 'LoggerFromParamConfigAs...'
  • v2.4 : Interaction with other systems. Part 1: wrapping seelog
    • Added configurable caller stack skip logic
    • Added 'SetAdditionalStackDepth' to 'LoggerInterface'
  • v2.3 : Rethinking 'rolling' receiver
    • Reimplemented 'rolling' receiver
    • Added 'Max rolls' feature for 'rolling' receiver with type='date'
    • Fixed 'rolling' receiver issue: renaming on Windows
  • v2.2 : go1.0 compatibility point [go1.0 tag]
    • Fixed internal bugs
    • Added 'ANSI n [;k]' format identifier: %EscN
    • Made current release go1 compatible
  • v2.1 : Some new features
    • Rolling receiver archiving option.
    • Added format identifier: %Line
    • Smtp: added paths to PEM files directories
    • Added format identifier: %FuncShort
    • Warn, Error and Critical methods now return an error
  • v2.0 : Second major release. BREAKING CHANGES.
    • Support of binaries with stripped symbols
    • Added log strategy: adaptive
    • Critical message now forces Flush()
    • Added predefined formats: xml-debug, xml-debug-short, xml, xml-short, json-debug, json-debug-short, json, json-short, debug, debug-short, fast
    • Added receiver: conn (network connection writer)
    • BREAKING CHANGE: added Tracef, Debugf, Infof, etc. to satisfy the print/printf principle
    • Bug fixes
  • v1.0 : Initial release. Features:
    • Xml config
    • Changing configurations on the fly without app restart
    • Contraints and exceptions
    • Formatting
    • Log strategies: sync, async loop, async timer
    • Receivers: buffered, console, file, rolling, smtp

seelog's People

Contributors

andrewzeneski avatar benmanns avatar cihub avatar dajohi avatar eyasuyuki avatar franklinwise avatar goodsign avatar iand avatar jmassara avatar jonsyu1 avatar lafriks avatar mlallaouret avatar obeattie avatar pkorotkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seelog's Issues

connection reset by peer

Hello,

(opening a separate issue for connection)

Without using reconnectonmsg="true" in client config file there is an error in seelog "connection reset by peer"

16:02:40 2012-08-29 [CRITICAL] testmessage
16:02:40 2012-08-29 [INFO] testinfomessage
Seelog error: write tcp 127.0.0.1:8525: connection reset by peer
16:02:40 2012-08-29 [CRITICAL] testmessage
16:02:40 2012-08-29 [INFO] testinfomessage
Seelog error: write tcp 127.0.0.1:8525: connection reset by peer
16:02:40 2012-08-29 [CRITICAL] testmessage
16:02:40 2012-08-29 [INFO] testinfomessage
Seelog error: write tcp 127.0.0.1:8525: connection reset by peer
16:02:40 2012-08-29 [CRITICAL] testmessage
16:02:40 2012-08-29 [INFO] testinfomessage
Seelog error: write tcp 127.0.0.1:8525: connection reset by peer

Server code:
package main

import (
"fmt"
"github.com/cihub/seelog"
"log"
"net"
"time"
)
var connections int

func handleClient(c net.Conn) {
connections += 1
defer c.Close()
}

func showprogress(){
var curr int
c := time.Tick(1 * time.Second)
for now := range c {
fmt.Println(now)
fmt.Println(connections-curr)
curr = connections
}

}

func main() {
logger, err := seelog.LoggerFromConfigAsFile("seelog-server.xml")

if err != nil {
    log.Fatal(err)
}
seelog.UseLogger(logger)
ln, err := net.Listen("tcp", ":8525")
if err != nil {
    seelog.Error(err)
}

go showprogress()
for {
    conn, err := ln.Accept()
    fmt.Printf("%d\r", connections)
    if err != nil {
        seelog.Error(err)
    }
    go handleClient(conn)
}

}

If "defer c.Close()" is not present logging will freeze after few dozen of lines. Can you please take a look on the issue?

(as a note to the previous issue, now, after using the "log" solution, the server logs between 800-1300 messages per second)
Thanks.

Add Fatalf and Panicf functions

It'd be nice to have these give the standard log system has them and they're useful. Also, question, does the critical level force a flush? The docs claim it does but then the example code calls flush itself after a critical log level which seems unnecessary.

How to create custom filters?

First off, thanks for a great library!

Not sure if I'm mis-reading the doco, but it seems that I cannot create a custom filter dispatcher which would:

  • allow me to inspect the message and its context to determine whether it should be forwarded (dispatched).
  • in some cases I would like to modify the context directly, before forwarding.

Just wanted to check whether these capabilities are present in seelog?

Cheers

Creating a LoggingInterface using a writer and as well as rolling files

First off, sorry if I missed this, but at the moment, we are supporting logging to console output as well as a rolling file via seelog configuration file, but what we really want to do is support rolling file as well as log to stderr.

We were able to log to stderr by creating a custom Writer implementation then creating a LoggingInterface from that, but then we loose the rolling file capabilities (and logging config in general).

Obviously, the easy solution is to use two separate LoggingInterfaces, but would be nice if we could use the same LoggingInterface for both (while we are using Stderr, we are not necessarily logging an error. The reasons for this are complicated and irrelevant for this post).

Is there a solution for this? For example, is there a way to programmatically construct a LoggingInterface implementation from config and then append a custom Writer implementation?

Change the naming pattern of rolling files?

If the datepattern is "2006-01-02", filename is "see.log". The rollingfile name will be seen like "2013-10-09 see.log". Could someone change the pattern to "see.log.2013-10-09" or something like this? Or more flexible patterns?

Count of emitted warnings/errors

It would be really nice to to have seelog count the number of Log messages it got for loglevels with small throughput (warn, etc.) so that a main program can set an descriptive exit status based on that.

Currently, you have to do that by yourself incrementing a variable each time you call log.Warn which is not that elegant...

Not all messages are written to log with multiple processes logging to same file

I have a program that logs in high volume to a single log file. If I start more than one of these, only some messages reach the log. For example, with two processes, approximately 1/2 the messages reach the log. With three, 2/3. With four, 3/4.

Note that these are multiple processes, not a single process using channels. It happens even if I flush after each message.

I suspect this is some kind of lock contention problem in the library. I am using the default logging behavior, and the newest release via go get github.com/cihub/seelog.

When I swapped out seelog with simply writing bytes to os.File, it works as expected: all messages are written to the log.

go get loads wrong version

I'm a bit confused. When I run

  • go get github.com/cihub/seelog
  • or go get github.com/cihub/seelog
    I end up with an old version of seelog.

I'm running go version go1.2 darwin/amd64 - but git branch shows:

* (detached from go1)
  master

Do you know what I'm doing wrong?

Examples for configuring with code

Neither can I nor do I want to use the xml format for logger configuration.

Sadly there are zero examples for configuring filters/receivers in code.

Could you add some?

How to create custom json log message format?

Is the below log message:-

{"level":"info", "message" : "hello world", "tId":"T12345", "reqId" : "R3232", "appId": "Discovery", "sessionId": "12325", "userId":"AB3435", "stackTraces" : ["Call Trace 1", "Call Trace 2"],  "timestamp" : "2015-07-09T18:00:00.875Z"}

where along with message, tId, reqId appId, sessionId and userId will be passed by caller.

Is it possible to achieve this using custom formatter?

Adaptive logger - wrong timesteamp

I have a problem with timestamps of messages when using adaptive logger.
Then each message have a timestamp from moment when it is written to disk (should be when it has been created)
When I switch to sync type, everything is ok.

first settings with wrong timestamps:
seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="debug"

this works:
seelog type="sync"

and the format I am using:
format id="simple" format="%Date('2006-01-02 15:04:05.000') [%l] %Msg%n"

Question:Is that "Colored output" surport on windows' cmd terminal?

I want to colorizing my log output on windows' cmd terminal and follow the setting here:https://github.com/cihub/seelog/wiki/Colorizing-output.
Here is my setting:

<seelog type="sync">
    <outputs formatid="debug">
        <console />
        <file path="debug.log" />
    </outputs>
    <formats>
        <format id="debug" format="[%EscM(46)%LEV%EscM(49)] [%RelFile-%FuncShort] : %Msg%n%EscM(0)" />
    </formats>
</seelog>

But it didn't work, and I've got output like:

F:\xxx>go run main.go
[�[46mINF�[49m] [main.go-main] : Listening on port:8001
�[0m[�[46mINF�[49m] [chat\server.go-Listen] : Listening server . . .
�[0m[�[46mINF�[49m] [chat\server.go-Listen] : Created handler
�[0m

So is that "Colored output" surport on windows' cmd terminal?

Using seelog as an io.Writer

Is there an example of where seelog implements the io.Writer interface so that it can be used to redirect output to?

Seelog panics on parsing error in config file

Seelog is not able to handle the following syntax error:

    <format id="nocolor-hrtime" format="%Date('02.01.2006/15:04:05' [%Lev] %FuncShort:%Msg%n"/>

with throwing an error.

1424719067522657234 [Critical] PANIC: runtime error: slice bounds out of range
1424719067522908091 [Debug] Stack of 1024 bytes: goroutine 16 [running]:
github.com/bong0/project/module.skeleton.Panic()
/home/user/dev/go/src/github.com/bong0/project/module/module.go:259 +0x166
github.com/bong0/project/module1.Panic·i(0x0)
<autogenerated>:33 +0x27
runtime.panic(0x767240, 0xbb4a8f)
/usr/lib/golang/src/pkg/runtime/panic.c:248 +0x18d
github.com/cihub/seelog.(*formatter).findparameter(0xc20804cbc0, 0x5, 0x0, 0x0, 0xc2080015b0, 0x1)
/home/bongo/dev/go/src/github.com/cihub/seelog/format.go:285 +0x13a
github.com/cihub/seelog.(*formatter).findFormatterFuncParametrized(0xc20804cbc0, 0xc208036a48, 0x4, 0x1, 0x0, 0x0, 0x748301)
/home/user/dev/go/src/github.com/cihub/seelog/format.go:258 +0x129
github.com/cihub/seelog.(*formatter).extractFormatterFunc(0xc20804cbc0, 0x1, 0x0, 0xbcc5b0, 0x0, 0x0)
/home/user/dev/go/src/github.com/cihub/seelog/format.go:209 +0x25d
github.com/cihub/seelog.(*formatter).buildFormatterFuncs(0xc20804cbc0, 0x0, 0x0)
/home/bongo/dev/go/src/github.com/cihub

1424719067522925949 [Trace] Cleanup() called

Instead it runs into my panic handler. Maybe log.ReplaceLogger(state.Logger) should return an error? I'm not sure

Console colors

Add attributes (and, possibly, child elements) to the element so that it would inject escape sequences to perform coloring of format verbs.

Could anyone modify the tag go1?

When "go get" the source code from github.com, Go 1.1.2/1.1.1 always look up the tag 'go1' first, then download the tag. But the "go1" tag of seelog is too old. Can anyone update the tag ?

Seelog rollingfile filename pattern not as expected

(Issue already on http://stackoverflow.com/questions/27179315/seelog-rollingfile-filename-pattern-not-as-expected and on https://groups.google.com/forum/#!topic/golang-nuts/Z4dRDOZRo_Y)

I have a seelog config file like

<seelog minlevel="info">
    <outputs>
        <console />
        <rollingfile type="date" datepattern="060201" filename="/tmp/-myApp.log" maxrolls="5" archivetype="none"/>
    </outputs>
</seelog>

What comes out are files like /tmp/-myApp.log.142711, I expected /tmp/142711-myApp.log as it is suggested at https://github.com/cihub/seelog/wiki/Receiver-reference qoute:

* In case of 'date' rolling, the file names will be formed this way:
   time.Now().Format(rollfileWriter.datePattern)+" "+rollFileWriter.fileName)

Can my expected behaviour be achieved somehow? Am I thinking in the wrong way?

using env variables in xml file

Hi,
Is it possible to define filename path dynamically, with an environment variable etc.
What I want to do is something like this:

<rollingfile type="date" filename="os.GetEnv(logpath)/roll.log" datepattern="02.01.2006"/>

seelog and systemd invalid argument error for every log message

When running my service by hand or in windows everything works as expected. When running the service under systemd I get this error before every log message: Seelog error: invalid argument

unit file:

[Unit]
Description=Logrhythm Rift Process that splits zmq pull streams
After=syslog.target network.target remote-fs.target nss-lookup.target network-online.target
Wants=network-online.target

[Service]
Type=simple
User=persistent
TimeoutSec=45s
Restart=always
WorkingDirectory=/usr/local/rift/
ExecStart=/home/vrecan/go/bin/rift

[Install]
WantedBy=multi-user.target

Tests fail?

I'm not sure how this is, since drone.io is obviously passing the build, but it's not passing for me.
This is using go 1.2 on Ubuntu 14.04 Trusty Tahr
I obtained the code by doing "go get -t github.com/cihub/seelog"

~/src/github.com/cihub/seelog$ go test
--- FAIL: TestContext (0.00 seconds)
    common_context_test.go:84: Expected context.ShortPath == common_context_test.go ; got /home/nate/code/src/github.com/cihub/seelog/common_context_test.go
    common_context_test.go:90: Expected context.FullPath == /home/nate/src/github.com/cihub/seelog/common_context_test.go ; got /home/nate/code/src/github.com/cihub/seelog/common_context_test.go
--- FAIL: TestInnerContext (0.00 seconds)
    common_context_test.go:119: Expected context.ShortPath == common_context_test.go ; got /home/nate/code/src/github.com/cihub/seelog/common_context_test.go
    common_context_test.go:125: Expected context.FullPath == /home/nate/src/github.com/cihub/seelog/common_context_test.go ; got /home/nate/code/src/github.com/cihub/seelog/common_context_test.go
FAIL
exit status 1
FAIL    github.com/cihub/seelog 0.054s

Different format based on log level

Hi,

We are considering using seelog in our go production environment, and the library looks great!
Quick question: is it possible to configure formats based on log levels? the use case would be to include the file/line numbers for ErrLvl and above:
Trace/Debug/Info: %Date %Time [%LEVEL] %Msg%n
Error/Critical: %Date %Time [%LEVEL] %Msg %RelFile %Func %Line%n

I looked at the filters, but can't find how to change the format based on a filter.

Thanks

Make formatter public

I'd like to set up a master process for aggregate logging from worker processes that send their messages using the connection writer. I also want to be able to log messages for the master process in the same log. However, short of parsing the worker messages in the master (or using some RPC scheme), I'm not sure if there's a way to do this in the library itself.

Do you see what I mean? Messages coming from the workers will already have the full log message according to my log format (date, time, log level, message). I can't push these things to the master because I don't know the log level, and I'd like to have the date and time as close to real as possible.

If the formatter were public I could make the log format "%Msg" and run all master messages through my own formatter through some helper function. This isn't the cleanest way to accomplish this (being able to select a format at the log function level would probably be it), but it has no backwards compatibility implications to the API.

To avoid BC breaking changes, you could add the following code to format.go:

type Formatter struct {
    formatter
}

func NewFormatter(formatString) (*Formatter, error) {
    f, err := newFormatter(formatString)
    return f, err
}

If you have other ideas about how to do this, please let me know. Thanks!

'Max rolls' feature for 'rolling' receiver with type='date' do not work for me.

'Max rolls' feature for 'rolling' receiver with type='date' do not work for me.
my code is follow.

    testConfig := `
<seelog>
    <outputs>
        <rollingfile type="date" filename="./log/roll.log" maxrolls="5" datepattern="02.01.2006"/>
    </outputs>
</seelog>
`
    logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
    log.ReplaceLogger(logger)
    fmt.Println("Rolling file writer")
    for i := 0; i < 10000; i++ {
        log.Tracef("%d", i)
        log.Infof("%d", i)
    }

image

the value of 'maxrolls' is 5. it should at most generate five files but there are six log file.
Is wrong the usage i used to log?
How can i fix the problem.

rename date rolling log till date changed

Hi,

I configured my application for logging date rolling log.

<outputs formatid="main">
        <console />
        <rollingfile type="date" filename="/var/log/test/api.log" datepattern="02.01.2006" maxrolls="14" />
</outputs>

For sure, the output file will be named as "api.log.25.06.2015", "api.log.24.06.2015" ... etc.

Assumption today is "25.06.2015".
May I know if any possible always to write today's log to "api.log" until the date changed to "26.06.2015".
It will rename the old log file "api.log" to "api.log.25.06.2015", and then start a new "api.log".

Thank you!

Config File Full

It would be helpful to see a full config file in one place with all of the various options. Right now the information about the config file options are spread out across many sections.

Errors when running without symbols

If you strip the symbols from the resulting binary during compilation then seelog fails when trying to log with:

Seelog error: Error during runtime.Caller

possible error on Info, Warning and Error logging.

Using the code below i get no display from logg.Info(val) but i do get some output if log.Println(val) it's added above logg.Info(val) eg.
for _, val := range a {
log.Println(val)
logg.Info(val)
}
Can you please have a look? Thanks.

package main

import (
"github.com/cihub/seelog"
"log"
)

func main() {
a := [...]string{"bla1", "bla2", "bla3"}
log.Println(len(a))
logg, err := seelog.LoggerFromConfigAsString(<seelog> <outputs formatid="common"> <console/> <rollingfile type="date" filename="backup.log" datepattern="02.01.2006"/> <filter levels="info,warn,error"> <rollingfile type="date" filename="backup.log" formatid="common" datepattern="02.01.2006"/> </filter> <filter levels="critical"> <rollingfile type="date" filename="backup.log" formatid="critical" datepattern="02.01.2006"/> </filter> </outputs> <formats> <format id="common" format="%Time %Date [%LEVEL] %Msg %n"/> <format id="critical" format="%Time %Date %RelFile %Func %Msg %n"/> </formats> </seelog>)
if err != nil {
log.Fatal(err)
}
for _, val := range a {
logg.Info(val)
}

}

replace "format string" with "v ...interface{}"

Why not to use "log" package approach http://golang.org/src/pkg/log/log.go?s=8456:8484#L276 where you can pass an interface to the logger?
Now you are using string and logger.Error(err) errors with type assertion, only logger.Error(err.Error()) would work because it's converted to string.
This is a proposal to make it better (it's very nice already).

Another thing is to be able to pass a connection to a logger (using conn) so it would not redial the server and a method to call the logger to close the connection once it's finished. Would you prefer to open this as a separate issue?
Thanks.

clients crash if runtime.GOMAXPROCS it's used in client code

Hi,
Not sure if it's related to seelog or runtime package, but adding runtime.GOMAXPROCS(runtime.NumCPU()) in func main() of client code makes the clients crash after some logging. In my case it happens when having more than 2 clients running.
You can use the same client code i gave for the previous issue to test.

Please find the error below:

14:39:17 2012-09-01 [WARN] open bla: no such file or directory
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x45e1a9]

goroutine 1 [running]:
container/list.(_List).insertBack(0xf8400c17e0, 0xf840166690, 0xf840166690, 0x41ed0c)
/usr/lib/go/src/pkg/container/list/list.go:133 +0x49
container/list.(_List).PushBack(0xf8400c17e0, 0x5b0c30, 0xf840166660, 0xf8401a38a0, 0xf8400bfa20, ...)
/usr/lib/go/src/pkg/container/list/list.go:146 +0x67
github.com/cihub/seelog.(_asyncLogger).addMsgToQueue(0xf840001e60, 0xf840001002, 0xf840001f00, 0xf8401a38a0, 0xf8400bfa20, ...)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclogger.go:127 +0x1ef
github.com/cihub/seelog.(_asyncLogger).innerLog(0xf840001e60, 0xf840001f02, 0xf840001f00, 0xf8401a38a0, 0xf8400bfa20, ...)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclogger.go:70 +0x59
github.com/cihub/seelog.(_commonLogger).log(0xf840001e10, 0x579a02, 0xf8400bfa20, 0xf8401aaef0, 0xf800000003, ...)
/usr/lib/go/src/pkg/github.com/cihub/seelog/logger.go:218 +0xdb
github.com/cihub/seelog.(_commonLogger).infoWithCallDepth(0xf840001e10, 0x100000003, 0xf8400bfa20, 0xf8401aaef0, 0x400f41, ...)
/usr/lib/go/src/pkg/github.com/cihub/seelog/logger.go:151 +0x48
github.com/cihub/seelog.(*commonLogger).Info(0xf840001e10, 0xf8401aaed0, 0x100000001, 0x527d68)
/usr/lib/go/src/pkg/github.com/cihub/seelog/logger.go:127 +0x62
main.main()
/home/ovidiu/Development/speedylogger-client-test.go:27 +0x341

goroutine 2 [syscall]:
created by runtime.main
/build/buildd/golang-1/src/pkg/runtime/proc.c:221

goroutine 3 [semacquire]:
sync.runtime_Semacquire(0xf8400749c0, 0xf8400749c0)
/build/buildd/golang-1/src/pkg/runtime/zsema_amd64.c:146 +0x25
sync.(_Cond).Wait(0xf8400b2b40, 0x400b1048)
/usr/lib/go/src/pkg/sync/cond.go:67 +0xaa
github.com/cihub/seelog.(_asyncLoopLogger).processItem(0xf840001b40, 0xf8400b1000, 0x40dd8f, 0xf840001b40)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:51 +0xc0
github.com/cihub/seelog.(*asyncLoopLogger).processQueue(0xf840001b40, 0x0)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:64 +0x2d
created by github.com/cihub/seelog.newAsyncLoopLogger
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:41 +0x69

goroutine 4 [semacquire]:
sync.runtime_Semacquire(0xf8400749c8, 0xf8400749c8)
/build/buildd/golang-1/src/pkg/runtime/zsema_amd64.c:146 +0x25
sync.(_Cond).Wait(0xf8400b2c40, 0x0)
/usr/lib/go/src/pkg/sync/cond.go:67 +0xaa
github.com/cihub/seelog.(_asyncLoopLogger).processItem(0xf840001c30, 0x0, 0x40dd8f, 0xf840001c30)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:51 +0xc0
github.com/cihub/seelog.(*asyncLoopLogger).processQueue(0xf840001c30, 0x0)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:64 +0x2d
created by github.com/cihub/seelog.newAsyncLoopLogger
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:41 +0x69

goroutine 5 [semacquire]:
sync.runtime_Semacquire(0xf840167250, 0xf840167250)
/build/buildd/golang-1/src/pkg/runtime/zsema_amd64.c:146 +0x25
sync.(_Cond).Wait(0xf8400c08c0, 0x0)
/usr/lib/go/src/pkg/sync/cond.go:67 +0xaa
github.com/cihub/seelog.(_asyncLoopLogger).processItem(0xf840001e10, 0xc3d00000000, 0x40dd8f, 0xf840001e10)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:51 +0xc0
github.com/cihub/seelog.(*asyncLoopLogger).processQueue(0xf840001e10, 0x0)
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:64 +0x2d
created by github.com/cihub/seelog.newAsyncLoopLogger
/usr/lib/go/src/pkg/github.com/cihub/seelog/behavior_asynclooplogger.go:41 +0x69

goroutine 6 [syscall]:
syscall.Syscall6()
/build/buildd/golang-1/src/pkg/syscall/asm_linux_amd64.s:40 +0x5
syscall.EpollWait(0xf800000007, 0xf8400d20c0, 0xa0000000a, 0xffffffff, 0xc, ...)
/usr/lib/go/src/pkg/syscall/zerrors_linux_amd64.go:1781 +0xa1
net.(_pollster).WaitFD(0xf8400d20b0, 0xf8400cd100, 0x0, 0x0, 0x0, ...)
/usr/lib/go/src/pkg/net/fd_linux.go:146 +0x110
net.(_pollServer).Run(0xf8400cd100, 0x0)
/usr/lib/go/src/pkg/net/fd.go:236 +0xe4
created by net.newPollServer
/usr/lib/go/src/pkg/net/newpollserver.go:35 +0x382
exit status 2

writers_smtpwriter.go 中有错误!!!

line 40 :rfc5321SubjectPattern = "From: %s <%s>\nSubject: %s\n"
应写为:rfc5321SubjectPattern = "From: %s <%s>\nSubject: %s\n\n"

否则接收方看到的邮件没有正文内容:),this tested on gmail、qq、139 。

retrieve writer for logger

Forgive me if there is already a way to do this, but I can't seem to find one.

Basically, the http pacakage supports logging by providing a log.Logger instance to a Server object. You can create a new log.Logger instance with log.New() and passing in a io.Writer implementation. Is there a way to get the io.Writer implementation for a seelog.LoggingInterface?

Would this even work? Basically, I need some way to capture the logging from the http pacakage. By default it just logs to stdout, so if there was even a way to just capture this output and reroute it through seelog, that would suffice.

questions for session base logging

Hi,

I'm integrating seelog with my http service. I would like to debug with a 'request id' per request/session.

My concept is, once http server receive a request, it will generate a UUID as the request id for this session.
All debug log will include this UUID for identifying till the end of request.

I've read a solution at Custom receivers - Scenario 3.2: Custom receivers with context, but I still had a concern there, please advice.

The concern is, when we instance the 'logger-per-request' log in HttpHandler per request (means it might be parallel),
should I take care of the performance and any potential issue()? I list cases for example:

  • create new logger with per-request-context every time might cause too many resource?
  • ReplaceLogger might be called at the middle of other session, does it cause other request use the incorrect request id? (one session might call debug() many times)
  • is that possible we log information via some variable in runtime?

Thank you, seelog rock! :)

Rotation config example

Is there any configuration example for logging with time interval rotation? For example daily? I wandered around the source code but it's not easy :) Can you provide/refer to a sample doc page or blogpost?

gorouine leak when ReplaceLogger

Hi,

I just found asnLoopLogger.closed had never been set as true.
When I try to ReplaceLogger in runtime with new config each time, one more gorouine stuck in func processItem at asnLoopLogger.queueHasElements.Wait(). That introduce a gorouine dead wait.

Could you take a look and fix it?

func (asnLoopLogger *asyncLoopLogger) processItem() (closed bool) {
    asnLoopLogger.queueHasElements.L.Lock()
    defer asnLoopLogger.queueHasElements.L.Unlock()

    for asnLoopLogger.msgQueue.Len() == 0 && !asnLoopLogger.closed {
        asnLoopLogger.queueHasElements.Wait()
    }

    if asnLoopLogger.closed {
        return true
    }

    asnLoopLogger.processQueueElement()
    return false
}

Test libraries linked with main seelog library binary

There appear to be several files that are used for testing only (e.g. internals_byteverifiers.go), that are not named _test.go. This causes these files to be built and linked with the actual library code.

Since these files use the "testing" package, that means that any program that uses the seelog package will get the testing package linked in as well. This causes the command line flags help for the program to display the flags associated with the "testing" package, which is inappropriate for a production binary.

Code that is for testing only (and which import "testing") should be put into _test.go files to avoid this problem.

go get fails

/usr/lib/go/src/pkg/github.com/cihub/seelog/internals_fsutils.go:208: fi.Mode().IsRegular undefined (type os.FileMode has no field or method IsRegular)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.