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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libs
log
Commits
ecd4b988
Commit
ecd4b988
authored
6 years ago
by
admin-sigmundd
Browse files
Options
Downloads
Patches
Plain Diff
Added Option to Add Tags
parent
ed7a8f33
Branches
Branches containing commit
Tags
Tags containing commit
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
+18
-7
18 additions, 7 deletions
README.md
index.js
+27
-15
27 additions, 15 deletions
index.js
samples/use-tags.js
+10
-0
10 additions, 0 deletions
samples/use-tags.js
with
55 additions
and
22 deletions
README.md
+
18
−
7
View file @
ecd4b988
...
...
@@ -12,16 +12,27 @@ May Optional Log to A File and / or a Graylog-Server
`const Log = require('log')`
`let log = new Log(options)`
Note: The options Part may be omitted, as all parts are optional, but using the name is recommended, as without it, the
folder
-name will be used
Note: The options Part may be omitted, as all parts are optional, but using the name is recommended, as without it, the
package
-name will be used
### Methods
*
`log.info('This is an Information')`
*
`log.notice('This is a Notice')`
*
`log.warn('This is a Warning')`
*
`log.error('This is an Error')`
*
`log.fatal('This is a Fatal Message')`
*
`log.debug('This is a Debug Message')`
*
`log.info('This is an Information' [, tags])`
*
`log.notice('This is a Notice' [, tags])`
*
`log.warn('This is a Warning' [, tags])`
*
`log.error('This is an Error' [, tags])`
*
`log.fatal('This is a Fatal Message' [, tags])`
*
`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
...
...
This diff is collapsed.
Click to expand it.
index.js
+
27
−
15
View file @
ecd4b988
...
...
@@ -14,29 +14,41 @@ function Log (options) {
if
(
this
.
options
.
file
)
{
this
.
fs
=
require
(
'
fs
'
)
}
this
.
info
=
function
(
message
)
{
this
.
log
(
'
INFO
'
,
message
)
this
.
info
=
function
(
message
,
tags
)
{
this
.
log
(
'
INFO
'
,
message
,
tags
)
}
this
.
notice
=
function
(
message
)
{
this
.
log
(
'
NOTICE
'
,
message
)
this
.
notice
=
function
(
message
,
tags
)
{
this
.
log
(
'
NOTICE
'
,
message
,
tags
)
}
this
.
fatal
=
function
(
message
)
{
this
.
log
(
'
FATAL
'
,
message
)
this
.
fatal
=
function
(
message
,
tags
)
{
this
.
log
(
'
FATAL
'
,
message
,
tags
)
}
this
.
warn
=
function
(
message
)
{
this
.
log
(
'
WARN
'
,
message
)
this
.
warn
=
function
(
message
,
tags
)
{
this
.
log
(
'
WARN
'
,
message
,
tags
)
}
this
.
error
=
function
(
message
)
{
this
.
log
(
'
ERROR
'
,
message
)
this
.
error
=
function
(
message
,
tags
)
{
this
.
log
(
'
ERROR
'
,
message
,
tags
)
}
this
.
debug
=
function
(
message
)
{
this
.
log
(
'
DEBUG
'
,
message
)
this
.
debug
=
function
(
message
,
tags
)
{
this
.
log
(
'
DEBUG
'
,
message
,
tags
)
}
this
.
log
=
function
(
tag
,
message
)
{
let
msg
=
this
.
getDate
()
+
'
\t
'
+
this
.
hostname
+
'
\t
'
+
this
.
name
+
'
\t
'
+
tag
+
'
\t
'
+
message
this
.
log
=
function
(
tag
,
message
,
tags
)
{
let
tadd
=
''
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
+
'
\t
'
+
tadd
switch
(
tag
)
{
case
'
INFO
'
:
console
.
log
(
msg
)
console
.
info
(
msg
)
break
case
'
NOTICE
'
:
console
.
log
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
samples/use-tags.js
0 → 100644
+
10
−
0
View file @
ecd4b988
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.
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