Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Hexang 息壤平台
persona
Commits
e18ae2f8
Commit
e18ae2f8
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
all of the metrics for a process should be put into a single file. issue #168.
parent
be2657af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/metrics.js
+16
-18
16 additions, 18 deletions
libs/metrics.js
with
16 additions
and
18 deletions
libs/metrics.js
+
16
−
18
View file @
e18ae2f8
...
...
@@ -61,7 +61,7 @@ fs = require('fs');
// FIXME: separate logs depending on purpose?
var
log_path
=
configuration
.
get
(
'
log_path
'
);
var
LOGGER
S
=
[]
;
var
LOGGER
;
// simple inline function for creation of dirs
function
mkdir_p
(
p
)
{
...
...
@@ -71,20 +71,18 @@ function mkdir_p(p) {
}
}
function
setupLogger
(
category
)
{
function
setupLogger
()
{
// don't create the logger if it already exists
if
(
LOGGER
)
return
;
if
(
!
log_path
)
return
console
.
log
(
"
no log path! Not logging!
"
);
else
mkdir_p
(
log_path
);
var
filename
=
path
.
join
(
log_path
,
"
metrics.json
"
);
// don't create the logger if it already exists
if
(
LOGGERS
[
category
])
return
;
var
filename
=
path
.
join
(
log_path
,
category
+
"
-log.txt
"
);
LOGGERS
[
category
]
=
new
(
winston
.
Logger
)({
LOGGER
=
new
(
winston
.
Logger
)({
transports
:
[
new
(
winston
.
transports
.
File
)({
filename
:
filename
})]
});
}
...
...
@@ -96,22 +94,22 @@ exports.report = function(category, entry) {
throw
new
Error
(
"
every log entry needs a type
"
);
// setup the logger if need be
setupLogger
(
category
);
setupLogger
();
// timestamp
entry
.
at
=
new
Date
().
toUTCString
();
// if no logger, go to console (FIXME: do we really want to log to console?)
LOGGER
S
[
category
]
.
info
(
JSON
.
stringify
(
entry
));
LOGGER
.
info
(
JSON
.
stringify
(
entry
));
};
// utility function to log a bunch of stuff at user entry point
exports
.
userEntry
=
function
(
category
,
req
)
{
exports
.
report
(
category
,
{
type
:
'
signin
'
,
browser
:
req
.
headers
[
'
user-agent
'
],
rp
:
req
.
headers
[
'
referer
'
],
// IP address (this probably needs to be replaced with the X-forwarded-for value
ip
:
req
.
connection
.
remoteAddress
});
};
\ No newline at end of file
type
:
'
signin
'
,
browser
:
req
.
headers
[
'
user-agent
'
],
rp
:
req
.
headers
[
'
referer
'
],
// IP address (this probably needs to be replaced with the X-forwarded-for value
ip
:
req
.
connection
.
remoteAddress
});
};
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