Skip to content

Commit fdef71b

Browse files
committed
create log and data dirs
1 parent 45989c2 commit fdef71b

File tree

5 files changed

+19
-187
lines changed

5 files changed

+19
-187
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8+
log.db
9+
log/
10+
11+
# Data generated by the app
12+
data/
813

914
# Diagnostic reports (https://nodejs.org/api/report.html)
1015
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ if (args.log == 'false') {
4646
console.log("NOTICE: not creating file access.log")
4747
} else {
4848
// Use morgan for logging to files
49+
const logdir = './log/';
50+
51+
if (!fs.existsSync(logdir)){
52+
fs.mkdirSync(logdir);
53+
}
4954
// Create a write stream to append to an access.log file
50-
const accessLog = fs.createWriteStream('access.log', { flags: 'a' })
55+
const accessLog = fs.createWriteStream( logdir+'access.log', { flags: 'a' })
5156
// Set up the access logging middleware
5257
app.use(morgan('combined', { stream: accessLog }))
5358
}

index.js~

Lines changed: 0 additions & 185 deletions
This file was deleted.

log.db

-212 KB
Binary file not shown.

src/services/database.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
const database = require('better-sqlite3')
22

3-
const logdb = new database('log.db')
3+
const fs = require('fs');
4+
const datadir = './data/';
5+
6+
if (!fs.existsSync(datadir)){
7+
fs.mkdirSync(datadir);
8+
}
9+
10+
const logdb = new database(datadir+'log.db')
411

512
const stmt = logdb.prepare(`SELECT name FROM sqlite_master WHERE type='table' and name='accesslog';`)
613
let row = stmt.get();

0 commit comments

Comments
 (0)