Skip to content

TS types #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"journald"
],
"author": "Jue <[email protected]>",
"contributors": ["Mikel Pérez <[email protected]>"],
"license": "MIT",
"main": "index.js",
"types": "types/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/jue89/node-systemd-journald.git"
Expand Down
43 changes: 43 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
declare module 'systemd-journald' {
// https://man7.org/linux/man-pages/man7/systemd.journal-fields.7.html
export type JournalFields = Partial<{
message_id: string,
code_file: string,
code_line: string,
code_func: string,
errno: string,
invocation_id: string,
user_invocation_id: string,
syslog_facility: string,
syslog_identifier: string,
syslog_pid: string,
syslog_timestamp: string,
syslog_raw: string,
documentation: string,
tid: string,
unit: string,
user_unit: string,
[custom_field: string]: string
}>

export default class systemd_journald {
constructor(defaultFields: JournalFields);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultFields is optional and can be omitted. Thus, change it like this?

Suggested change
constructor(defaultFields: JournalFields);
constructor(defaultFields?: JournalFields);

Just guesstimating here :D

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my reasoning was that you wouldn't instantiate it and would use the static methods if you didn't want to provide defaults.
if you'd rather it be optional here too I'll accept the change


alert(message: string, fields?: JournalFields): void;
crit(message: string, fields?: JournalFields): void;
debug(message: string, fields?: JournalFields): void;
emerg(message: string, fields?: JournalFields): void;
err(message: string, fields?: JournalFields): void;
info(message: string, fields?: JournalFields): void;
notice(message: string, fields?: JournalFields): void;
warning(message: string, fields?: JournalFields): void;
static alert(message: string, fields?: JournalFields): void;
static crit(message: string, fields?: JournalFields): void;
static debug(message: string, fields?: JournalFields): void;
static emerg(message: string, fields?: JournalFields): void;
static err(message: string, fields?: JournalFields): void;
static info(message: string, fields?: JournalFields): void;
static notice(message: string, fields?: JournalFields): void;
static warning(message: string, fields?: JournalFields): void;
}
}