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
4e06613a
Commit
4e06613a
authored
13 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
logging now supports multiple log files
parent
b7bcbed1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
browserid/app.js
+1
-1
1 addition, 1 deletion
browserid/app.js
libs/configuration.js
+7
-4
7 additions, 4 deletions
libs/configuration.js
libs/logging.js
+22
-12
22 additions, 12 deletions
libs/logging.js
verifier/app.js
+3
-3
3 additions, 3 deletions
verifier/app.js
with
33 additions
and
20 deletions
browserid/app.js
+
1
−
1
View file @
4e06613a
...
...
@@ -42,7 +42,7 @@ function router(app) {
// this should probably be an internal redirect
// as soon as relative paths are figured out.
app
.
get
(
'
/sign_in
'
,
function
(
req
,
res
,
next
)
{
logging
.
userEntry
(
req
);
logging
.
userEntry
(
'
browserid
'
,
req
);
res
.
render
(
'
dialog.ejs
'
,
{
title
:
'
A Better Way to Sign In
'
,
layout
:
false
,
...
...
This diff is collapsed.
Click to expand it.
libs/configuration.js
+
7
−
4
View file @
4e06613a
...
...
@@ -25,26 +25,29 @@ const g_configs = {
hostname
:
'
browserid.org
'
,
port
:
'
443
'
,
scheme
:
'
https
'
,
use_minified_resources
:
true
use_minified_resources
:
true
,
log_path
:
'
/home/browserid/var/
'
},
development
:
{
hostname
:
'
dev.diresworb.org
'
,
port
:
'
443
'
,
scheme
:
'
https
'
,
use_minified_resources
:
true
use_minified_resources
:
true
,
log_path
:
'
/home/browserid/var/
'
},
beta
:
{
hostname
:
'
diresworb.org
'
,
port
:
'
443
'
,
scheme
:
'
https
'
,
use_minified_resources
:
true
use_minified_resources
:
true
,
log_path
:
'
/home/browserid/var/
'
},
local
:
{
hostname
:
'
127.0.0.1
'
,
port
:
'
10002
'
,
scheme
:
'
http
'
,
use_minified_resources
:
false
,
log_path
:
'
log.txt
'
log_path
:
'
./
'
}
};
...
...
This diff is collapsed.
Click to expand it.
libs/logging.js
+
22
−
12
View file @
4e06613a
...
...
@@ -6,37 +6,47 @@ const configuration = require("./configuration");
// FIXME: separate logs depending on purpose?
var
log_path
=
configuration
.
get
(
'
log_path
'
);
var
LOGGER
=
null
;
if
(
log_path
)
{
LOGGER
=
new
(
winston
.
Logger
)({
transports
:
[
new
(
winston
.
transports
.
File
)({
filename
:
log_path
})]
var
LOGGERS
=
[];
function
setupLogger
(
category
)
{
if
(
!
log_path
)
return
console
.
log
(
"
no log path! Not logging!
"
);
// don't create the logger if it already exists
if
(
LOGGERS
[
category
])
return
;
// FIXME: check if log_path is properly terminated
var
filename
=
log_path
+
category
+
"
-log.txt
"
;
LOGGERS
[
category
]
=
new
(
winston
.
Logger
)({
transports
:
[
new
(
winston
.
transports
.
File
)({
filename
:
filename
})]
});
}
// entry is an object that will get JSON'ified
exports
.
log
=
function
(
entry
)
{
exports
.
log
=
function
(
category
,
entry
)
{
// entry must have at least a type
if
(
!
entry
.
type
)
throw
new
Error
(
"
every log entry needs a type
"
);
// setup the logger if need be
setupLogger
(
category
);
// timestamp
entry
.
at
=
new
Date
().
toUTCString
();
// if no logger, go to console (FIXME: do we really want to log to console?)
if
(
LOGGER
)
LOGGER
.
info
(
JSON
.
stringify
(
entry
));
else
winston
.
info
(
JSON
.
stringify
(
entry
));
LOGGERS
[
category
].
info
(
JSON
.
stringify
(
entry
));
};
// utility function to log a bunch of stuff at user entry point
exports
.
userEntry
=
function
(
req
)
{
exports
.
log
({
exports
.
userEntry
=
function
(
category
,
req
)
{
exports
.
log
(
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
});
console
.
log
(
JSON
.
stringify
(
req
.
headers
));
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
verifier/app.js
+
3
−
3
View file @
4e06613a
...
...
@@ -37,7 +37,7 @@ function doVerify(req, resp, next) {
audience
,
function
(
payload
)
{
// log it!
logging
.
log
({
logging
.
log
(
'
verifier
'
,
{
type
:
'
verify
'
,
result
:
'
success
'
,
rp
:
payload
.
audience
...
...
@@ -53,7 +53,7 @@ function doVerify(req, resp, next) {
resp
.
json
(
result
);
},
function
(
errorObj
)
{
logging
.
log
({
logging
.
log
(
'
verifier
'
,
{
type
:
'
verify
'
,
result
:
'
failure
'
,
rp
:
audience
...
...
@@ -63,7 +63,7 @@ function doVerify(req, resp, next) {
);
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
logging
.
log
({
logging
.
log
(
'
verifier
'
,
{
type
:
'
verify
'
,
result
:
'
failure
'
,
rp
:
audience
...
...
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