All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fix possible race condition on
sypl.SetMaxLevel
- Add badges to README.md:
- GoDoc
- Go Report Card
- Build Status
- Coverage Status
- License
- Release
- Flag should be an array.
- Move
Options
' methods fromMessage
toOptions
- Improve documentation:
- Add
doc.go
for all packages
- Add
Refs. for badges:
- All
SetXYZ
methods returns its proper interface allowing method chaining. Breakpoint
is now variadic.- Properly handle cases where sypl writes to a piped output, but it's broken.
- Fixed
ExampleNew_globalFields
test.
Added the ability to set breakpoints. If a Breakpoint
is set it'll stop execution waiting the user press /n
("enter") to continue. It helps users doing quick, and effective log-to-console debug. A message with the breakpoint name
, and PID
of the process will be printed using the debug
level. Arbitrary data
can optionally be set - if set, it'll be printed. Errors are printed using the standard error
level. Set logging level to trace
for more.
Previously, flow would look like:
- Log markers are set, e.g.:
logger.Debugln("Here 1", whatever)
- Application runs
- Scan visually
output
, or afile
- viagrep
for the markers.
Now:
- Named
Breakpoint
s are set - Application runs
- Breakpoint is hit. Information about it is printed.
- Runtime is paused, allowing analysis of
data
- if any, right way. Additionally, an external and more advanced debugger can be attached. - Dev controls the flow, pressing
enter
at any time, continue.
- Exported
sypl.Name
to deal with golang/go#5819.
In a application with many loggers, and child loggers, sometimes more fine control is needed, specially when debugging applications. Sypl offers two powerful ways to achieve that: SYPL_FILTER
, and SYPL_DEBUG
env vars.
SYPL_FILTER
allows to specify the name(s) of the component(s) that should be logged, for example, for a given application with the following loggers: svc
, pv
, and cm
, if a developer wants only to see svc
, and pv
logging, it's achieved just setting SYPL_FILTER="svc,pv"
.
SYPL_DEBUG
allows to specify the max level, for example, for a given application with the following loggers: svc
, pv
, and cm
, if a developer sets:
SYPL_DEBUG="debug"
: any application running using Sypl, any component, any output, will log messages bellow thedebug
levelSYPL_DEBUG="console:debug"
: any application running using Sypl with an output calledconsole
, will log messages bellow thedebug
levelSYPL_DEBUG="warn,console:debug"
: any application running using Sypl, any component, any output, will log messages bellow thewarn
level, AND any application running using Sypl with an output calledconsole
, will log messages bellow thedebug
level.
NOTE: warn
is specified first. Only for this case - global scope, it's a requirement.
SYPL_DEBUG="console:debug,warn"
: In this case warn
will be discarded!.
SYPL_DEBUG="svc:console:debug"
: any application running using Sypl with a component calledsvc
with an output calledconsole
, will log messages bellow thedebug
levelSYPL_DEBUG="file:warn,svc:console:debug"
: any application running using Sypl with an output calledfile
will log messages bellow thewarn
level, and any application running using Sypl with a component calledsvc
with an output calledconsole
will log messages bellow thedebug
.
Possible scopes:
{componentName:outputName:level}
: Component, and output scoped.{outputName:level}
: Output scoped.{level}
: Global scope.
The possibilities are endless! Checkout the debugAndFilter
example for more.
- Renamed logging component filtering env var from
SYPL_DEBUG
toSYPL_FILTER
.
- Fix bug where setting fields for a message would set globally too.
- Level
FromString
, andMustFromString
methods validates iflevel
param is empty.
- Sypl
SetFields
is chainable.
- Adds the ability to set global Fields.
FromString
error now prints also available levels.LevelsNames
returns lower-cased levels.
StdErr
now only printsError
ANDFatal
instead of onlyError
.Console
now ignoresError
ANDFatal
instead of onlyError
.PrintOnlyAtLevel
now handle multiples levels.FromString
now returns the level, and error instead of level, and bool (ok).- Internal
sypl.process
is now validated. In case of failure it throwsErrSyplNotInitialized
. - All
error.go
files were renamed toerrors.go
, following Go standards.
- Adds
PrintNewLine
.
Skip
andSkipAndForce
flags now skips formatters too.
- Removes unused entries from
Makefile
. sypl.New
now returns*Sypl
.
- Adds
PrintMessagesToOutputsWithOptions
.
- Allows to specify the name of
dashHandler
output.- Now, when
-
is specified as a path,dashHandler
is named after the original output.
- Now, when
- Fixed names of the factories, so it doesn't stutters.
Note: Breaking change.
- Adds
LevelsNames
.
- Improved
FromString
.
- Adds
MustFromString
.
- Adds the ability to get and set outputs' max level.
NewDefault
only prints errors tostderr
.
- Adds
PrintOnlyIfTagged
built-in processor.
- Renames
PrintOnlyLevel
toPrintOnlyAtLevel
.
StdErr
only prints @Error
Level
.
- Creates
StdErr
built-inOutput
.
- Removes
path
(unused) fromFileBased
Output
.
- Improved linebreak detection and restoration.
- Adds
PrintMessagerPerOutput
which allows you to concurrently print messages, each one, at the specified level and to the specified output. If the named output doesn't exits, the message will not be printed.- Cover with test.
- Adds
output
field toText
andJSON
formatters.
- Adds the ability to create child loggers (
New
). The child logger is an accurate, and efficient shallow copy of the parent logger. Changes to internals, such as the state of outputs, and processors, are reflected cross all other loggers. - Adds
Text
, andJSON
formatters. It also process fields. Seeexample_test.go/ExampleNew_textFormatter
andexample_test.go/ExampleNew_jsonFormatter
for examples. Both formatters automatically adds:- Component name
- Level
- Timestamp (RFC3339).
- Add more tests. Covered
ErrorSimulator
processor. - Adds ability to filter logging message. See
example_test.go/ExampleNew_childLoggers
for example. Having many loggers can be, sometimes, noisy. Also, sometimes - for debugging reason, you may want to see onlycomponentA
, andcomponentC
. Now, it's possible. Just specify the name of the components (comma-separated list) in theSYPL_DEBUG
env var.
- Adds support for structured logging.
- See
example_test.go/ExampleNew_fieldsProcessing
.
- See
- Components are interface(behaviour)-driven (design-pattern).
- Components are Factory built (design-pattern).
- Adds
Buffer
built-inoutput
, it's a concurrent-safe buffer. - Refactored code, components are packaged.
- Adds the
Decolourizer
processor.
- Go mod checksum.
- Adds
Sprint{f|lnf|ln}
, and{Level}{f|lnf|ln}
Convenient methods. It's yourSprint
, orSinfo
(example) but also returning the non-processed content.
Before:
// ...
var errMsg := "Some error"
logger.Errorln(errMsg)
return errors.New(errMsg)
Now:
// ...
return logger.Serrorln("Some error") // Prints and process like `Errorln`, and returns an error.
- Fixes
Flag
s processing logic. - Covers
Flag
s with test.
- Fixes
prettify
not printing the error if it fails.
- Finer-control on message's behaviour with two new
Flags
:SkipAndForce
andSkipAndMute
. - Adds
Printlnf
, and{Level}{lnf}
Convenient methods. It's yourPrintf
, orInfof
(example) without the need to add"\n"
to the format - less annoying repetition.
Before:
// ...
exampleContent := "example"
logger.Printf("Something %s\n", exampleContent)
Now:
// ...
exampleContent := "example"
logger.Printlnf("Something %s", exampleContent)
- Improves testability, and maintainability: All "Convenient methods" are based on "Base methods" that are based on the implementation of the interface.
- Testability: You mock the interface, and have full control over how it works.
- Maintainability: You change the interface implementation, you change how everything works.
- Fix typo (
spyl
).
- Adds
Print{ln}Pretty
which allows to print data structures as JSON text.
Now:
// ...
logger.PrintlnPretty(&SomeStruct{
nonExportedKey: "Value1",
SomeExportedKey: "Value2",
})
// Prints:
// {
// "SomeExportedKey": "Value2"
// }
- Prefixes sypl errors making it easier to identify when happens.
- Fixes a bug in
level.FromString
where invalid string would calllog.Fatal
.
- Adds the ability to tag a message, see new
Print{f,ln}WithOptions
example. - Adds the ability to flag a message, see new
Skip
flag. - Adds
Print{f,ln}WithOptions
which allows to specify message'sOptions
such as a list ofOutput
s andProcessor
s to be used. - Functional approach: no direct-access to data structure properties.
- Adds more examples.
- Adds more tests.
- Adds more documentation.
- Extracted
Flag
,Content
andLevel
to packages.
- First release.