Commit Graph

267 Commits

Author SHA1 Message Date
dependabot[bot]
5e6ec5804d
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 06:09:31 +00:00
Chelsea Hoover
263b0bde36
#411 Add FieldsExclude parameter to console writer (#418) 2022-02-27 18:33:36 +01:00
Nick Corin
588a61c2df
ctx: Modify WithContext to use a non-pointer receiver (#409) 2022-02-24 01:17:11 +01:00
Mitar
361cdf616a
Remove extra space in console when there is no message (#413) 2022-02-19 16:39:18 +01:00
RobRimmer
fc26014bd4
MsgFunc function added to Event (#406)
Allows lazy evaluation of msg text, only if log level is appropriate.
2022-02-03 15:03:11 +01:00
Nicola Murino
025f9f1819
journald: don't call Enabled before each write (#407)
Enabled opens and close a socket connection by reusing or initializing
a global connection.

I also updated go-systemd to the current development release to include
the following fix:

75f33b08db

This is the only journal related change since the latest stable release
2022-02-03 14:49:04 +01:00
Arnau
3efdd82416
call done function when logger is disabled (#393) 2022-01-04 17:12:02 +01:00
nichady
c0c2e11fc3
Consistent casing, redundancy, and spelling/grammar (#391)
* fix casing
* remove redundant type conversions
* remove unnecessary append
x = append(y) is equivalent to x = y
* fix grammar and spelling
* rename file to enforce consistent casing with other READMEs in this repo
2021-12-21 13:07:54 +01:00
nichady
665519c4da
Fix ConsoleWriter color on Windows (#390)
* fix ConsoleWriter colors on windows
* fix ConsoleWriter color when created with struct literal
2021-12-19 23:50:53 +01:00
Nicola Murino
0c8d3c0b10
move the lint command to its own package (#389)
in this way we remove several dependencies from the actual library
2021-12-17 03:03:37 +01:00
Chris Harrison
791ca15d99
Update the x/crypto dependency
Removing the security concern brought up by third parties

Co-authored-by: Chris Harrison <chris.harrison@modicagroup.com>

Fixes #387
2021-12-16 00:37:18 +01:00
Asger Noer
0d2f0be4ee
fix: error field name color (#377) 2021-11-09 12:34:43 +01:00
Federico G. Schwindt
6973188a74
Add support for dicts in array (#375)
Fixes #111.
2021-11-02 01:53:02 +01:00
Edward McFarlane
78448ee023
New TestWriter for logging to testing.TB (#369) 2021-10-05 01:07:40 +02:00
dependabot[bot]
197adb44cc
Bump golang.org/x/tools from 0.1.5 to 0.1.7 (#370)
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.1.5 to 0.1.7.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.1.5...v0.1.7)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-04 12:59:57 +02:00
hn8
07d347e658
Update zerologr url (#364)
Transferred to go-logr
2021-09-25 09:57:54 +02:00
Matas
6f8a5f9ccb
Add Stringers support (#360) 2021-09-18 19:22:21 +02:00
hn8
9b9fc5c6b7
Update zerologr url (#359)
Transferred from hn8 to screenleap.
2021-09-14 13:27:57 +02:00
hn8
65adfd88ec
Make Fields method accept both map and slice (#352) 2021-09-08 18:00:06 +02:00
Tim Hockin
cdd74175d0
Allow arbitrary negative levels (#350)
This allows logr to use high V() levels.
2021-08-27 22:34:08 +02:00
Tyler Cosgrove
fe931004ff
Make RemoteAddrHandler copy the RemoteAddr untouched (#347)
Do not remove the port part of the RemoteAddr and accept values with no ports.
2021-08-19 20:46:16 +02:00
Matthieu MOREL
be6f6fd8f1
chore(ci) : update dependencies (#345)
* Create dependabot.yml
* Update test.yml
* Bump golang.org/x/tools from 0.1.3 to 0.1.5 (#1)
* Bump github.com/rs/xid from 1.2.1 to 1.3.0 (#2)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-16 11:47:56 +02:00
Sean
d92a906fca
Allow user configuration of which logger to return from Ctx() (#343)
If a user is trying to fetch a logger from their context, they probably
want to log something.  In order to allow returning a useable logger from Ctx()
without breaking backwards compatibilty with the previous behavior, we make it
configurable.
2021-08-12 02:18:16 +02:00
Steve Carlson
fad20d83d3
docs: sampler typo (#342)
fix BasicSampler docstring typo

Co-authored-by: Steve Carlson <steve.carlson@crowdstrike.com>
2021-08-10 21:43:41 +02:00
hn8
164ec91b0c
Add logr implementation to README and json.RawMessage to Fields() (#337) 2021-08-03 11:31:54 +02:00
Spike^ekipS
c1533bd5f8
patched; panic Event.Object() and Event.EmbedObject() with nil (#338) 2021-08-01 17:24:18 +02:00
adw1n
0872592ea2
Make default console formatter work with customized level names (#330) 2021-07-15 22:04:15 +02:00
Eugene Klimov
da1cb97713
Update x/tools dependency 2021-06-23 17:16:12 +02:00
adw1n
117cb53bc6
Fix copying stack setting in logger's Output method (#325)
Minimum example to reproduce the problem:
```go
package main

import (
	"os"

	"github.com/pkg/errors"
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
	"github.com/rs/zerolog/pkgerrors"
)

func main() {
	log.Logger = log.With().Caller().Stack().Logger().Output(zerolog.ConsoleWriter{Out: os.Stderr})
	zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack

	log.Info().Err(errors.New("test")).Send()
}
```
Without my changes `stack` isn't printed.
2021-06-07 12:16:53 +02:00
Mitsuo Heijo
e05605c215
Use github.com/coreos/go-systemd/v22 (#322) 2021-05-23 10:29:31 +02:00
Olivier Poitrey
6ed1127758 Fix panic on disabled event with CallerSkipFrame
Fixes #319
2021-05-20 18:40:53 +02:00
povsister
47a03bc5eb
Add ability to customize internal json marshaler (#318)
Added a package level variable "InterfaceMarshalFunc".
It's used to marshal interface to JSON encoded byte slice,
mostly when event.Interface("key", v) is called.
2021-05-20 14:46:36 +02:00
Marcus Watkins
ffbd37b8d7
Add Func log method (#321)
This adds the Func log method to log using an anonymous function
only if the level is currently enabled.

The use case is for when you don't own an object and therefore can't
create your own marshaller but need to do some translation prior to
logging.

For example, this:

msg := log.Debug()
if msg.Enabled() {
  msg.Str("complicated_thing", makeBinaryThingLoggable(thing))
}
msg.Msg("Sending complicated thing")

Turns into this:

log.Debug().
  Func(func(e *Event) { e.Str("complicated_thing", makeBinaryThingLoggable(thing)) }).
  Msg("Sending complicated thing")
2021-05-20 01:33:11 +02:00
Olivier Poitrey
3c3b4a354e Add ability to customize level values 2021-05-14 00:07:21 +02:00
Zephaniah Loss-Cutler-Hull
4de2fcc128
Fix handling of printing caller with Write, Print, and Printf. (#315)
* Add event.CallerSkipFrame(skip int)

This indicates that, for this event, we should skip an additional
specified number of frames.

This is cumulative, calling it twice for the same event will add both
numbers together, and this is in addition to any skip frame settings set
through the context, or globally.

The indended purpose is for wrappers to Msg or Msgf, so that the actual
caller is always printed correctly.

* Use CallerSkipFrame for Print, Printf, and Write.

This allows us to use the correct caller when using these 3 functions.

Co-authored-by: Zephaniah E. Loss-Cutler-Hull <warp@aehallh.com>
2021-05-13 17:22:27 +02:00
Olivier Poitrey
f09463fbe1 Migrate to github actions 2021-05-05 15:10:23 +02:00
Tabitha
19c98f6d3e
If LevelFieldName is empty don't log level (#313) 2021-05-05 14:40:45 +02:00
Jack Christensen
0f923d7926
Fix: mutil.fancyWriter.ReadFrom records number of bytes written (#256)
Without this hlog.AccessHnalder reports a size written of 0 when the
ReadFrom method is used. This is easily visible when using
http.FileServer where all files are served with a logged size of 0.
2021-04-22 03:22:35 +02:00
Dan Gillis
582f0cf0e3
add Disabled to String and ParseLevel; add tests (#307) 2021-04-13 07:32:06 +02:00
Olivier Poitrey
98f889fcde Revert "Fix Typo (#306)"
This reverts commit f85e803cc5.
2021-04-07 19:58:46 +02:00
Redha Juanda
f85e803cc5
Fix Typo (#306) 2021-04-07 16:12:54 +02:00
Ben Visness
f2cc3cf8b7
Fix Context.Stack() (#303) 2021-03-23 23:01:01 +01:00
Emre Arslan
72b5b1ea58
added overlog to related project (#302)
Co-authored-by: Emre Arslan <emre.arslan@trendyol.com>
2021-03-18 16:21:38 +01:00
Jean Morais
7ccd4c940b
Bump golang.org/x/tools to v0.1.0 (#295)
Fixes #291: There is a known vulnerability in one of the golang.org/x/tools dependencies [CVE-2019-11840].
2021-03-03 00:42:31 +01:00
Dan Gillis
7a3aa8746f
Allow setting context using idKey. Assist for issue #293. (#296) 2021-03-02 11:01:32 +01:00
Nuno Diegues
a8f5328bb7
Make MultiLevelWriter resilient to individual log failure (#282)
Fixes #281

Currently MultiLevelWriter would give up if any individual backing logger
failed. This could result in no logging ever happening if the bad logger
was set up in the first position.

As a motivating factor, this can happen in "normal" circumstances, such
as running as a Windows Service where stderr is not available and therefore
the ConsoleWriter will fail. If you happen to set it as the first logger,
then no logging ever takes place. To make matters worse, connecting a
debugger creates an stderr, so it made it a pretty daunting situation
to overcome.

The proposed solution is to go through all underlying loggers and return
the last error obtained, if any. In practice there isn't much being done
with those errors anyway, as the best way to address logging errors is
to hook a ErrorHandler, which will still be triggered despite this change.

Co-authored-by: Nuno Diegues <nuno@cloudflare.com>
2021-01-20 17:03:52 +01:00
Eng Zer Jun
4f50ae2ed0
build: update github.com/pkg/errors from 0.8.1 to 0.9.1 (#280)
* [ImgBot] Optimize images

/pretty.png -- 141.30kb -> 82.09kb (41.9%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* build: update pkg/errors from 0.8.1 to 0.9.1

According to pkg/errors 0.9.0 release[1], they have reduced the
allocations for stacktrace.

[1]: https://github.com/pkg/errors/releases/tag/v0.9.0

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2021-01-11 11:12:13 +01:00
Dan Gillis
0aba2e4ae5
Add Error logging section and section links (#275) 2020-12-30 00:57:10 +01:00
Jason McVetta
a3b272d512
Test newer Go versions (#276) 2020-12-29 21:23:45 +01:00
Jason McVetta
b7e31f4fe7
Log relative path for caller when using ConsoleWriter (#267)
* use relative file path
2020-12-28 22:38:24 +01:00