Exemplo n.º 1
0
// WithContextFields adds a "context" field containing the caller's
// function name and source file line number. Use this function
// when the log has fields. Note that any existing "context" field
// will be renamed to "field.context".
func (logger *ContextLogger) WithContextFields(fields LogFields) *logrus.Entry {
	_, ok := fields["context"]
	if ok {
		fields["fields.context"] = fields["context"]
	}
	fields["context"] = psiphon.GetParentContext()
	return log.WithFields(logrus.Fields(fields))
}
Exemplo n.º 2
0
// LogRawFieldsWithTimestamp directly logs the supplied fields adding only
// an additional "timestamp" field. The stock "msg" and "level" fields are
// omitted. This log is emitted at the Error level. This function exists to
// support API logs which have neither a natural message nor severity; and
// omitting these values here makes it easier to ship these logs to existing
// API log consumers.
func (logger *ContextLogger) LogRawFieldsWithTimestamp(fields LogFields) {
	logger.WithFields(logrus.Fields(fields)).Error(
		customJSONFormatterLogRawFieldsWithTimestamp)
}