Skip to content

Commit e8fbaf7

Browse files
authored
Merge pull request #10 for v0.7.0 Release
2 parents 7ff095b + 52a527f commit e8fbaf7

File tree

9 files changed

+85
-36
lines changed

9 files changed

+85
-36
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ branches:
77
# skip tags build, we are building branch and master that is enough for
88
# consistenty check and release. Let's use Travis CI resources optimally
99
# for aah framework.
10-
- /^v[0-9]\.[0-9]/
10+
- /^v[0-9.]+$/
1111

1212
go:
13-
- 1.8
14-
- 1.9
13+
- 1.9.x
14+
- 1.x
1515
- tip
1616

1717
go_import_path: aahframework.org/log.v0

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016-2017 Jeevanandam M., https://myjeeva.com <[email protected]>
3+
Copyright (c) 2016-2018 Jeevanandam M., https://myjeeva.com <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# log - aah framework
2-
[![Build Status](https://travis-ci.org/go-aah/log.svg?branch=master)](https://travis-ci.org/go-aah/log) [![codecov](https://codecov.io/gh/go-aah/log/branch/master/graph/badge.svg)](https://codecov.io/gh/go-aah/log/branch/master) [![Go Report Card](https://goreportcard.com/badge/aahframework.org/log.v0)](https://goreportcard.com/report/aahframework.org/log.v0)
3-
[![Version](https://img.shields.io/badge/version-0.6-blue.svg)](https://github.com/go-aah/log/releases/latest) [![GoDoc](https://godoc.org/aahframework.org/log.v0?status.svg)](https://godoc.org/aahframework.org/log.v0)
4-
[![License](https://img.shields.io/github/license/go-aah/log.svg)](LICENSE)
1+
<p align="center">
2+
<img src="https://cdn.aahframework.org/assets/img/aah-logo-64x64.png" />
3+
<h2 align="center">Logger by aah framework</h2>
4+
</p>
5+
<p align="center">
6+
<p align="center"><a href="https://travis-ci.org/go-aah/log"><img src="https://travis-ci.org/go-aah/log.svg?branch=master" alt="Build Status"></a> <a href="https://codecov.io/gh/go-aah/log/branch/master"><img src="https://codecov.io/gh/go-aah/log/branch/master/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/aahframework.org/log.v0"><img src="https://goreportcard.com/badge/aahframework.org/log.v0" alt="Go Report Card"></a> <a href="https://github.com/go-aah/log/releases/latest"><img src="https://img.shields.io/badge/version-0.7.0-blue.svg" alt="Release Version"></a> <a href="https://godoc.org/aahframework.org/log.v0"><img src="https://godoc.org/aahframework.org/log.v0?status.svg" alt="Godoc"></a> <a href="https://twitter.com/aahframework"><img src="https://img.shields.io/badge/[email protected]" alt="Twitter @aahframework"></a></p>
7+
</p>
58

6-
***v0.6 [released](https://github.com/go-aah/log/releases/latest) and tagged on Oct 02, 2017***
9+
aah logger is simple and provides capabilities to fulfill application use cases.
710

8-
Simple, flexible & powerful `Go` logger inspired by standard logger & Google glog. aah framework utilizes `log` library across.
11+
### News
912

10-
*`log` developed for aah framework. However, it's an independent library, can be used separately with any `Go` language project. Feel free to use it.*
13+
* `v0.7.0` [released](https://github.com/go-aah/log/releases/latest) and tagged on Jun 24, 2018.
1114

12-
# Installation
13-
#### Stable Version - Production Ready
14-
```sh
15-
# install the library
15+
## Installation
16+
17+
```bash
1618
go get -u aahframework.org/log.v0
1719
```
1820

19-
Visit official website https://aahframework.org to learn more.
21+
Visit official website https://aahframework.org to learn more about `aah` framework.

console_receiver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
LevelError: []byte("\033[0;31m"), // red
2626
LevelWarn: []byte("\033[0;33m"), // yellow
2727
LevelInfo: []byte("\033[0;37m"), // white
28-
LevelDebug: []byte("\033[0;34m"), // blue
28+
LevelDebug: []byte("\033[0;36m"), // cyan
2929
LevelTrace: []byte("\033[0;35m"), // magenta (purple)
3030
}
3131

entry.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"bytes"
99
"encoding/json"
1010
"fmt"
11+
slog "log"
1112
"strings"
1213
"sync"
1314
"time"
@@ -194,6 +195,50 @@ func (e *Entry) Panicln(v ...interface{}) {
194195
panic(e)
195196
}
196197

198+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
199+
// Entry level methods
200+
//___________________________________
201+
202+
// IsLevelInfo method returns true if log level is INFO otherwise false.
203+
func (e *Entry) IsLevelInfo() bool {
204+
return e.logger.IsLevelInfo()
205+
}
206+
207+
// IsLevelError method returns true if log level is ERROR otherwise false.
208+
func (e *Entry) IsLevelError() bool {
209+
return e.logger.IsLevelError()
210+
}
211+
212+
// IsLevelWarn method returns true if log level is WARN otherwise false.
213+
func (e *Entry) IsLevelWarn() bool {
214+
return e.logger.IsLevelWarn()
215+
}
216+
217+
// IsLevelDebug method returns true if log level is DEBUG otherwise false.
218+
func (e *Entry) IsLevelDebug() bool {
219+
return e.logger.IsLevelDebug()
220+
}
221+
222+
// IsLevelTrace method returns true if log level is TRACE otherwise false.
223+
func (e *Entry) IsLevelTrace() bool {
224+
return e.logger.IsLevelTrace()
225+
}
226+
227+
// IsLevelFatal method returns true if log level is FATAL otherwise false.
228+
func (e *Entry) IsLevelFatal() bool {
229+
return e.logger.IsLevelFatal()
230+
}
231+
232+
// IsLevelPanic method returns true if log level is PANIC otherwise false.
233+
func (e *Entry) IsLevelPanic() bool {
234+
return e.logger.IsLevelPanic()
235+
}
236+
237+
// ToGoLogger method wraps the current log writer into Go Logger instance.
238+
func (e *Entry) ToGoLogger() *slog.Logger {
239+
return e.logger.ToGoLogger()
240+
}
241+
197242
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
198243
// Entry context/field methods
199244
//_______________________________________

file_receiver.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,7 @@ func (f *FileReceiver) rotateFile() error {
175175
}
176176
}
177177

178-
if err := f.openFile(); err != nil {
179-
return err
180-
}
181-
182-
return nil
178+
return f.openFile()
183179
}
184180

185181
func (f *FileReceiver) openFile() error {

formatter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package log
66

77
import (
8+
"bytes"
89
"fmt"
910
"path/filepath"
1011
"strings"
@@ -98,8 +99,7 @@ var (
9899
// For e.g.:
99100
// 2016-07-02 22:26:01.530 INFO formatter_test.go L29 - Yes, I would love to see
100101
func textFormatter(flags []ess.FmtFlagPart, entry *Entry) []byte {
101-
buf := acquireBuffer()
102-
defer releaseBuffer(buf)
102+
buf := new(bytes.Buffer)
103103

104104
for _, part := range flags {
105105
switch part.Flag {

log.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
// Copyright (c) Jeevanandam M (https://github.com/jeevatkm)
2-
// go-aah/log source code and usage is governed by a MIT style
2+
// aahframework.org/log source code and usage is governed by a MIT style
33
// license that can be found in the LICENSE file.
44

5-
// Package log implements a simple, flexible, non-blocking logger.
6-
// It supports `console`, `file` (rotation by daily, size, lines).
7-
// It also has a predefined 'standard' Logger accessible through helper
8-
// functions `Error{f}`, `Warn{f}`, `Info{f}`, `Debug{f}`, `Trace{f}`,
9-
// `Print{f,ln}`, `Fatal{f,ln}`, `Panic{f,ln}` which are easier to use than creating
10-
// a Logger manually. Default logger writes to standard error and prints log
11-
// `Entry` details as per `DefaultPattern`.
5+
// Package log simple logger and provides capabilities to fulfill application
6+
// use cases. It supports two receivers `console` and `file` and extensible
7+
// by interface and Hook.
128
//
13-
// aah log package can be used as drop-in replacement for standard go logger
14-
// with features.
9+
// Also provides standard logger crossover binding (drop-in replacement
10+
// for standard go logger) for unified logging.
1511
//
1612
// log.Info("Welcome ", "to ", "aah ", "logger")
1713
// log.Infof("%v, %v, %v", "simple", "flexible", "logger")
@@ -107,7 +103,17 @@ type (
107103
WithFields(fields Fields) Loggerer
108104
WithField(key string, value interface{}) Loggerer
109105

106+
// Level Info
107+
IsLevelInfo() bool
108+
IsLevelError() bool
109+
IsLevelWarn() bool
110+
IsLevelDebug() bool
111+
IsLevelTrace() bool
112+
IsLevelFatal() bool
113+
IsLevelPanic() bool
114+
110115
// For standard logger drop-in replacement
116+
ToGoLogger() *slog.Logger
111117
Print(v ...interface{})
112118
Printf(format string, v ...interface{})
113119
Println(v ...interface{})

version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Jeevanandam M (https://github.com/jeevatkm)
2-
// go-aah/log source code and usage is governed by a MIT style
2+
// aahframework.org/log source code and usage is governed by a MIT style
33
// license that can be found in the LICENSE file.
44

55
package log
66

77
// Version no. of aahframework.org/log library
8-
const Version = "0.6"
8+
const Version = "0.7.0"

0 commit comments

Comments
 (0)