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
19cd1393
Commit
19cd1393
authored
5 years ago
by
Sigmund, Dominik
Browse files
Options
Downloads
Patches
Plain Diff
Removed Tag-Option
parent
9e965aab
No related branches found
No related tags found
1 merge request
!1
Update index.test.js, examples/all-options.js, examples/log-to-file.js,...
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+7
-18
7 additions, 18 deletions
README.md
index.js
+14
-26
14 additions, 26 deletions
index.js
package.json
+1
-1
1 addition, 1 deletion
package.json
with
22 additions
and
45 deletions
README.md
+
7
−
18
View file @
19cd1393
# log.js
# log.js
A real simple logger application.
A real simple logger application.
May Optional Log to A File
and / or a Graylog-Server
May Optional Log to A File
.
## Installation
## Installation
...
@@ -16,23 +16,12 @@ Note: The options Part may be omitted, as all parts are optional, but using the
...
@@ -16,23 +16,12 @@ Note: The options Part may be omitted, as all parts are optional, but using the
### Methods
### Methods
*
`log.info('This is an Information' )`
*
`log.info('This is an Information' [, tags])`
*
`log.notice('This is a Notice' )`
*
`log.notice('This is a Notice' [, tags])`
*
`log.warn('This is a Warning' )`
*
`log.warn('This is a Warning' [, tags])`
*
`log.error('This is an Error' )`
*
`log.error('This is an Error' [, tags])`
*
`log.fatal('This is a Fatal Message' )`
*
`log.fatal('This is a Fatal Message' [, tags])`
*
`log.debug('This is a Debug Message' )`
*
`log.debug('This is a Debug Message' [, tags])`
You may add Tags to a logline. These Tags may take the following forms:
*
string = 'tag'
*
string, seperated by whitespace = 'tag1 tag2 tag3'
*
string, seperated by comma = 'tag1,tag2,tag3'
*
array of strings = ['tag1', 'tag2', 'tag3']
These Tags will be added to the line with octothorpes added.
(#tag1 #tag2 #tag3)
### Options
### Options
...
...
This diff is collapsed.
Click to expand it.
index.js
+
14
−
26
View file @
19cd1393
...
@@ -41,62 +41,50 @@ function Log (options) {
...
@@ -41,62 +41,50 @@ function Log (options) {
}
}
}
}
}
}
this
.
info
=
function
(
message
,
tags
)
{
this
.
info
=
function
(
message
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
INFO
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
INFO
)
{
return
this
.
log
(
'
INFO
'
,
message
,
tags
)
return
this
.
log
(
'
INFO
'
,
message
)
}
else
{
}
else
{
return
''
return
''
}
}
}
}
this
.
notice
=
function
(
message
,
tags
)
{
this
.
notice
=
function
(
message
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
NOTICE
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
NOTICE
)
{
return
this
.
log
(
'
NOTICE
'
,
message
,
tags
)
return
this
.
log
(
'
NOTICE
'
,
message
)
}
else
{
}
else
{
return
''
return
''
}
}
}
}
this
.
fatal
=
function
(
message
,
tags
)
{
this
.
fatal
=
function
(
message
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
FATAL
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
FATAL
)
{
return
this
.
log
(
'
FATAL
'
,
message
,
tags
)
return
this
.
log
(
'
FATAL
'
,
message
)
}
else
{
}
else
{
return
''
return
''
}
}
}
}
this
.
warn
=
function
(
message
,
tags
)
{
this
.
warn
=
function
(
message
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
WARN
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
WARN
)
{
return
this
.
log
(
'
WARN
'
,
message
,
tags
)
return
this
.
log
(
'
WARN
'
,
message
)
}
else
{
}
else
{
return
''
return
''
}
}
}
}
this
.
error
=
function
(
message
,
tags
)
{
this
.
error
=
function
(
message
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
ERROR
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
ERROR
)
{
return
this
.
log
(
'
ERROR
'
,
message
,
tags
)
return
this
.
log
(
'
ERROR
'
,
message
)
}
else
{
}
else
{
return
''
return
''
}
}
}
}
this
.
debug
=
function
(
message
,
tags
)
{
this
.
debug
=
function
(
message
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
DEBUG
)
{
if
(
this
.
loglevel
>=
this
.
levels
.
DEBUG
)
{
return
this
.
log
(
'
DEBUG
'
,
message
,
tags
)
return
this
.
log
(
'
DEBUG
'
,
message
)
}
else
{
}
else
{
return
''
return
''
}
}
}
}
this
.
log
=
function
(
tag
,
message
,
tags
)
{
this
.
log
=
function
(
tag
,
message
)
{
let
tadd
=
''
let
msg
=
this
.
getDate
()
+
'
\t
'
+
this
.
hostname
+
'
\t
'
+
this
.
name
+
'
\t
'
+
tag
+
'
\t
'
+
message
if
(
typeof
tags
!==
'
undefined
'
)
{
if
(
Array
.
isArray
(
tags
))
{
tadd
=
'
#
'
+
tags
.
join
(
'
#
'
)
}
else
if
(
tags
.
includes
(
'
'
))
{
tadd
=
'
#
'
+
tags
.
split
(
'
'
).
join
(
'
#
'
)
}
else
if
(
tags
.
includes
(
'
,
'
))
{
tadd
=
'
#
'
+
tags
.
split
(
'
,
'
).
join
(
'
#
'
)
}
else
{
tadd
=
'
#
'
+
tags
}
}
let
msg
=
this
.
getDate
()
+
'
\t
'
+
this
.
hostname
+
'
\t
'
+
this
.
name
+
'
\t
'
+
tag
+
'
\t
'
+
message
+
tadd
switch
(
tag
)
{
switch
(
tag
)
{
case
'
INFO
'
:
case
'
INFO
'
:
console
.
info
(
msg
)
console
.
info
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
19cd1393
{
{
"name"
:
"lib-log"
,
"name"
:
"lib-log"
,
"version"
:
"
1.1
.0"
,
"version"
:
"
2.0
.0"
,
"description"
:
"A simple Logger with Options!"
,
"description"
:
"A simple Logger with Options!"
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
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