diff options
| author | Tom Harley | 2018-04-26 05:05:49 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-04-26 05:05:49 +0100 |
| commit | f0331e27eab9e699529183b0dc2dd1bc9599aea5 (patch) | |
| tree | c7c09b1d77006bf7aceb7c3bf1c23910c9a55168 /src/logger.ts | |
| parent | Miscellaneous minor fixes (diff) | |
| parent | pushing for tom to get changes (diff) | |
| download | medicine-f0331e27eab9e699529183b0dc2dd1bc9599aea5.tar.gz medicine-f0331e27eab9e699529183b0dc2dd1bc9599aea5.zip | |
Merge branch ‘trh/gets’ of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/project-code into trh/gets
Diffstat (limited to 'src/logger.ts')
| -rw-r--r-- | src/logger.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/logger.ts b/src/logger.ts index aa8192c..bed8f72 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -2,9 +2,20 @@ import * as colors from 'colors/safe'; import * as winston from 'winston'; +import { profiler } from './profiler' import { logPath } from './files'; import { QueryOptions } from 'sequelize'; +const dbQuery = profiler.meter({ + name: "Database Requests Per Minute", + samples: 60, + timeframe: 60 +}) +const dbTime = profiler.histogram({ + name: "Time to Serve DB requests (ms)", + measurement: "mean", + agg_type: "avg" +}) type Colour = (s: string) => string; @@ -388,6 +399,8 @@ export const logger: Logger = setDefaults({ user: '_BE4_system', component: 'cor export const logQuery: (query: string, duration: string) => void = ( query: string, duration: string ): void => { + dbQuery.mark(); + dbTime.update(Number(duration)); queryLogger.info(query, { duration }); |
