Skip to content

Commit 1c4a852

Browse files
committed
Use matching console.* methods
Fixes #6. This is a breaking change. We could add it to the end but the function parameters were already getting long so I think an object works better. Also decreased the wrapping width.
1 parent beba925 commit 1c4a852

File tree

4 files changed

+144
-81
lines changed

4 files changed

+144
-81
lines changed

.prettierrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
printWidth: 120
1+
printWidth: 95
22
semi: false
33
trailingComma: all
44
arrowParens: always

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"prepare": "tsc",
77
"test": "jest"
88
},
9-
"version": "1.1.16",
9+
"version": "2.0.0",
1010
"main": "out/index.js",
1111
"types": "out/index.d.ts",
1212
"author": "Coder",

src/extender.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as gcl from "@google-cloud/logging"
2-
import { Extender, logger, field } from "./logger"
2+
import { Extender, field, Level, logger } from "./logger"
33

44
export const createStackdriverExtender = (projectId: string, logId: string): Extender => {
55
const logging = new gcl.Logging({
@@ -8,24 +8,22 @@ export const createStackdriverExtender = (projectId: string, logId: string): Ext
88
})
99

1010
const log = logging.log(logId)
11-
const convertSeverity = (
12-
severity: "trace" | "info" | "warn" | "debug" | "error",
13-
): gcl.protos.google.logging.type.LogSeverity => {
11+
const convertSeverity = (severity: Level): gcl.protos.google.logging.type.LogSeverity => {
1412
switch (severity) {
15-
case "trace":
16-
case "debug":
13+
case Level.Trace:
14+
case Level.Debug:
1715
return gcl.protos.google.logging.type.LogSeverity.DEBUG
18-
case "info":
16+
case Level.Info:
1917
return gcl.protos.google.logging.type.LogSeverity.INFO
20-
case "error":
21-
return gcl.protos.google.logging.type.LogSeverity.ERROR
22-
case "warn":
18+
case Level.Warning:
2319
return gcl.protos.google.logging.type.LogSeverity.WARNING
20+
case Level.Error:
21+
return gcl.protos.google.logging.type.LogSeverity.ERROR
2422
}
2523
}
2624

2725
return (options): void => {
28-
const severity = convertSeverity(options.type)
26+
const severity = convertSeverity(options.level)
2927
const metadata: { [id: string]: string } = {}
3028
if (options.fields) {
3129
options.fields.forEach((f) => {
@@ -37,9 +35,7 @@ export const createStackdriverExtender = (projectId: string, logId: string): Ext
3735
}
3836

3937
const entry = log.entry(
40-
{
41-
severity: severity,
42-
},
38+
{ severity },
4339
{
4440
...metadata,
4541
message: options.message,

0 commit comments

Comments
 (0)