Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
086b5948
Commit
086b5948
authored
Jun 11, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(loggin): disable logging by default so unit tests are not full of logging
parent
1584dac0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
13 deletions
+7
-13
pkg/log/log.go
+1
-0
pkg/middleware/quota.go
+2
-5
pkg/services/sqlstore/datasource_test.go
+1
-3
pkg/services/sqlstore/migrations/migrations_test.go
+0
-2
pkg/services/sqlstore/migrator/migrator.go
+1
-1
pkg/services/sqlstore/sqlstore.go
+2
-2
No files found.
pkg/log/log.go
View file @
086b5948
...
@@ -22,6 +22,7 @@ var loggersToClose []DisposableHandler
...
@@ -22,6 +22,7 @@ var loggersToClose []DisposableHandler
func
init
()
{
func
init
()
{
loggersToClose
=
make
([]
DisposableHandler
,
0
)
loggersToClose
=
make
([]
DisposableHandler
,
0
)
Root
=
log15
.
Root
()
Root
=
log15
.
Root
()
Root
.
SetHandler
(
log15
.
DiscardHandler
())
}
}
func
New
(
logger
string
,
ctx
...
interface
{})
Logger
{
func
New
(
logger
string
,
ctx
...
interface
{})
Logger
{
...
...
pkg/middleware/quota.go
View file @
086b5948
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"fmt"
"fmt"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log"
m
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/setting"
"gopkg.in/macaron.v1"
"gopkg.in/macaron.v1"
...
@@ -35,10 +34,8 @@ func QuotaReached(c *Context, target string) (bool, error) {
...
@@ -35,10 +34,8 @@ func QuotaReached(c *Context, target string) (bool, error) {
return
false
,
err
return
false
,
err
}
}
log
.
Debug
(
fmt
.
Sprintf
(
"checking quota for %s in scopes %v"
,
target
,
scopes
))
for
_
,
scope
:=
range
scopes
{
for
_
,
scope
:=
range
scopes
{
log
.
Debug
(
fmt
.
Sprintf
(
"checking scope %s"
,
scope
.
Name
)
)
c
.
Logger
.
Debug
(
"Checking quota"
,
"target"
,
target
,
"scope"
,
scope
)
switch
scope
.
Name
{
switch
scope
.
Name
{
case
"global"
:
case
"global"
:
...
@@ -51,7 +48,7 @@ func QuotaReached(c *Context, target string) (bool, error) {
...
@@ -51,7 +48,7 @@ func QuotaReached(c *Context, target string) (bool, error) {
if
target
==
"session"
{
if
target
==
"session"
{
usedSessions
:=
getSessionCount
()
usedSessions
:=
getSessionCount
()
if
int64
(
usedSessions
)
>
scope
.
DefaultLimit
{
if
int64
(
usedSessions
)
>
scope
.
DefaultLimit
{
log
.
Debug
(
fmt
.
Sprintf
(
"%d sessions active, limit is %d"
,
usedSessions
,
scope
.
DefaultLimit
)
)
c
.
Logger
.
Debug
(
"Sessions limit reached"
,
"active"
,
usedSessions
,
"limit"
,
scope
.
DefaultLimit
)
return
true
,
nil
return
true
,
nil
}
}
continue
continue
...
...
pkg/services/sqlstore/datasource_test.go
View file @
086b5948
...
@@ -12,8 +12,6 @@ import (
...
@@ -12,8 +12,6 @@ import (
)
)
func
InitTestDB
(
t
*
testing
.
T
)
{
func
InitTestDB
(
t
*
testing
.
T
)
{
t
.
Log
(
"InitTestDB"
)
x
,
err
:=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Sqlite3
.
DriverName
,
sqlutil
.
TestDB_Sqlite3
.
ConnStr
)
x
,
err
:=
xorm
.
NewEngine
(
sqlutil
.
TestDB_Sqlite3
.
DriverName
,
sqlutil
.
TestDB_Sqlite3
.
ConnStr
)
//x, err := xorm.NewEngine(sqlutil.TestDB_Mysql.DriverName, sqlutil.TestDB_Mysql.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Mysql.DriverName, sqlutil.TestDB_Mysql.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Postgres.DriverName, sqlutil.TestDB_Postgres.ConnStr)
//x, err := xorm.NewEngine(sqlutil.TestDB_Postgres.DriverName, sqlutil.TestDB_Postgres.ConnStr)
...
@@ -24,7 +22,7 @@ func InitTestDB(t *testing.T) {
...
@@ -24,7 +22,7 @@ func InitTestDB(t *testing.T) {
sqlutil
.
CleanDB
(
x
)
sqlutil
.
CleanDB
(
x
)
if
err
:=
SetEngine
(
x
,
false
);
err
!=
nil
{
if
err
:=
SetEngine
(
x
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
}
}
...
...
pkg/services/sqlstore/migrations/migrations_test.go
View file @
086b5948
...
@@ -6,7 +6,6 @@ import (
...
@@ -6,7 +6,6 @@ import (
"github.com/go-xorm/xorm"
"github.com/go-xorm/xorm"
.
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
.
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
"github.com/inconshreveable/log15"
.
"github.com/smartystreets/goconvey/convey"
.
"github.com/smartystreets/goconvey/convey"
)
)
...
@@ -29,7 +28,6 @@ func TestMigrations(t *testing.T) {
...
@@ -29,7 +28,6 @@ func TestMigrations(t *testing.T) {
sqlutil
.
CleanDB
(
x
)
sqlutil
.
CleanDB
(
x
)
mg
:=
NewMigrator
(
x
)
mg
:=
NewMigrator
(
x
)
mg
.
Logger
.
SetHandler
(
log15
.
DiscardHandler
())
AddMigrations
(
mg
)
AddMigrations
(
mg
)
err
=
mg
.
Start
()
err
=
mg
.
Start
()
...
...
pkg/services/sqlstore/migrator/migrator.go
View file @
086b5948
...
@@ -107,7 +107,7 @@ func (mg *Migrator) Start() error {
...
@@ -107,7 +107,7 @@ func (mg *Migrator) Start() error {
}
}
func
(
mg
*
Migrator
)
exec
(
m
Migration
)
error
{
func
(
mg
*
Migrator
)
exec
(
m
Migration
)
error
{
log
.
Info
(
"Executing migration"
,
"id"
,
m
.
Id
())
mg
.
Logger
.
Info
(
"Executing migration"
,
"id"
,
m
.
Id
())
err
:=
mg
.
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
err
:=
mg
.
inTransaction
(
func
(
sess
*
xorm
.
Session
)
error
{
...
...
pkg/services/sqlstore/sqlstore.go
View file @
086b5948
...
@@ -78,7 +78,7 @@ func NewEngine() {
...
@@ -78,7 +78,7 @@ func NewEngine() {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
err
=
SetEngine
(
x
,
setting
.
Env
==
setting
.
DEV
)
err
=
SetEngine
(
x
)
if
err
!=
nil
{
if
err
!=
nil
{
sqlog
.
Error
(
"Fail to initialize orm engine"
,
"error"
,
err
)
sqlog
.
Error
(
"Fail to initialize orm engine"
,
"error"
,
err
)
...
@@ -86,7 +86,7 @@ func NewEngine() {
...
@@ -86,7 +86,7 @@ func NewEngine() {
}
}
}
}
func
SetEngine
(
engine
*
xorm
.
Engine
,
enableLog
bool
)
(
err
error
)
{
func
SetEngine
(
engine
*
xorm
.
Engine
)
(
err
error
)
{
x
=
engine
x
=
engine
dialect
=
migrator
.
NewDialect
(
x
.
DriverName
())
dialect
=
migrator
.
NewDialect
(
x
.
DriverName
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment