Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
log
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libs
log
Commits
3b5f30ab
Commit
3b5f30ab
authored
6 years ago
by
Sigmund, Dominik
Browse files
Options
Downloads
Patches
Plain Diff
Added LogLevel-Control
parent
fe4d9b6d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Update index.test.js, examples/all-options.js, examples/log-to-file.js,...
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
index.js
+43
-6
43 additions, 6 deletions
index.js
package.json
+2
-1
2 additions, 1 deletion
package.json
samples/use-tags.js
+10
-10
10 additions, 10 deletions
samples/use-tags.js
tests/test.js
+468
-468
468 additions, 468 deletions
tests/test.js
with
523 additions
and
485 deletions
index.js
+
43
−
6
View file @
3b5f30ab
function
Log
(
options
)
{
this
.
levels
=
{
'
DEBUG
'
:
5
,
'
INFO
'
:
4
,
'
NOTICE
'
:
3
,
'
WARN
'
:
2
,
'
ERROR
'
:
1
,
'
FATAL
'
:
0
}
this
.
options
=
options
||
{}
if
(
this
.
options
.
loglevel
)
{
// DEBUG, INFO, NOTICE, WARN, ERROR, FATAL
this
.
loglevel
=
this
.
levels
[
this
.
options
.
loglevel
]
}
else
{
this
.
loglevel
=
2
}
if
(
this
.
options
.
name
)
{
this
.
name
=
this
.
options
.
name
}
else
{
...
...
@@ -15,22 +28,46 @@ function Log (options) {
this
.
fs
=
require
(
'
fs
'
)
}
this
.
info
=
function
(
message
,
tags
)
{
return
this
.
log
(
'
INFO
'
,
message
,
tags
)
if
(
this
.
loglevel
>=
this
.
levels
.
INFO
)
{
return
this
.
log
(
'
INFO
'
,
message
,
tags
)
}
else
{
return
''
}
}
this
.
notice
=
function
(
message
,
tags
)
{
return
this
.
log
(
'
NOTICE
'
,
message
,
tags
)
if
(
this
.
loglevel
>=
this
.
levels
.
NOTICE
)
{
return
this
.
log
(
'
NOTICE
'
,
message
,
tags
)
}
else
{
return
''
}
}
this
.
fatal
=
function
(
message
,
tags
)
{
return
this
.
log
(
'
FATAL
'
,
message
,
tags
)
if
(
this
.
loglevel
>=
this
.
levels
.
FATAL
)
{
return
this
.
log
(
'
FATAL
'
,
message
,
tags
)
}
else
{
return
''
}
}
this
.
warn
=
function
(
message
,
tags
)
{
return
this
.
log
(
'
WARN
'
,
message
,
tags
)
if
(
this
.
loglevel
>=
this
.
levels
.
WARN
)
{
return
this
.
log
(
'
WARN
'
,
message
,
tags
)
}
else
{
return
''
}
}
this
.
error
=
function
(
message
,
tags
)
{
return
this
.
log
(
'
ERROR
'
,
message
,
tags
)
if
(
this
.
loglevel
>=
this
.
levels
.
ERROR
)
{
return
this
.
log
(
'
ERROR
'
,
message
,
tags
)
}
else
{
return
''
}
}
this
.
debug
=
function
(
message
,
tags
)
{
return
this
.
log
(
'
DEBUG
'
,
message
,
tags
)
if
(
this
.
loglevel
>=
this
.
levels
.
DEBUG
)
{
return
this
.
log
(
'
DEBUG
'
,
message
,
tags
)
}
else
{
return
''
}
}
this
.
log
=
function
(
tag
,
message
,
tags
)
{
let
tadd
=
''
...
...
This diff is collapsed.
Click to expand it.
package.json
+
2
−
1
View file @
3b5f30ab
...
...
@@ -4,7 +4,8 @@
"description"
:
"A simple Logger with Options!"
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"nyc --reporter=html --reporter=text mocha -- tests/test.js && rsync --remove-source-files -av --progress ./coverage ./docs/ && rm -Rf ./coverage"
,
"test"
:
"mocha tests/test.js"
,
"test-coverage"
:
"nyc --reporter=html --reporter=text mocha -- tests/test.js && rsync --remove-source-files -av --progress ./coverage ./docs/ && rm -Rf ./coverage"
,
"test-graphics"
:
"nyc --reporter=html --reporter=text mocha -R mochawesome -- tests/test.js && rsync --remove-source-files -av --progress ./coverage ./docs/ && rm -Rf ./coverage && rsync --remove-source-files -av --progress ./mochawesome-report ./docs/ && rm -Rf ./mochawesome-report"
},
"author"
:
"Dominik Sigmund"
,
...
...
This diff is collapsed.
Click to expand it.
samples/use-tags.js
+
10
−
10
View file @
3b5f30ab
const
Log
=
require
(
'
../index.js
'
)
let
log
=
new
Log
()
log
.
info
(
'
This is an Information
'
,
'
info
'
)
log
.
notice
(
'
This is a Notice
'
,
'
notice system ping
'
)
log
.
warn
(
'
This is a Warning
'
,
'
some,tags,added
'
)
log
.
error
(
'
This is an Error
'
,
[
'
tag
'
,
'
error
'
,
'
crit
'
,
'
api
'
])
log
.
debug
(
'
This is a Debug Message
'
)
log
.
fatal
(
'
This is a Fatal Message
'
)
const
Log
=
require
(
'
../index.js
'
)
let
log
=
new
Log
()
log
.
info
(
'
This is an Information
'
,
'
info
'
)
log
.
notice
(
'
This is a Notice
'
,
'
notice system ping
'
)
log
.
warn
(
'
This is a Warning
'
,
'
some,tags,added
'
)
log
.
error
(
'
This is an Error
'
,
[
'
tag
'
,
'
error
'
,
'
crit
'
,
'
api
'
])
log
.
debug
(
'
This is a Debug Message
'
)
log
.
fatal
(
'
This is a Fatal Message
'
)
This diff is collapsed.
Click to expand it.
tests/test.js
+
468
−
468
View file @
3b5f30ab
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment