Last active
January 30, 2023 21:05
-
-
Save tomfa/668a1a4b07f01e112667cbe629d33a92 to your computer and use it in GitHub Desktop.
LogStructure.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ApplicationLog = { | |
level: 'debug' | 'info' | 'warning' | 'danger' | 'critical', | |
message: string, | |
createdAt: number, | |
userId?: string, | |
// a business metric, e.g. SIGNUP | |
action?: string, | |
monetaryValue?: number, | |
requestId?: string, | |
// Common fields depending on your use case | |
oldValue?: string, | |
value?: string, | |
comment?: string, | |
// Handle custom cases | |
[key: string]: any; | |
} | |
// You typically don't control this type yourself. | |
// It's determined by your hosting provider. But | |
// it typically includes at least this info. | |
type HTTPLog = { | |
request: { | |
method: 'GET' | 'POST' | 'PATCH' | 'DELETE' | 'PUT', | |
path: string, | |
query?: string, | |
ipAddress: string, | |
headers: { | |
requestId?: string, | |
} | |
// ... | |
}, | |
response: { | |
httpStatus: number, | |
responseTime: number, | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment