@@ -372,6 +372,16 @@ const (
372
372
SD_JOURNAL_FIELD_CURSOR = "__CURSOR"
373
373
SD_JOURNAL_FIELD_REALTIME_TIMESTAMP = "__REALTIME_TIMESTAMP"
374
374
SD_JOURNAL_FIELD_MONOTONIC_TIMESTAMP = "__MONOTONIC_TIMESTAMP"
375
+
376
+ // Journal Flags
377
+ SD_JOURNAL_FLAG_LOCAL_ONLY = int (C .SD_JOURNAL_LOCAL_ONLY )
378
+ SD_JOURNAL_FLAG_RUNTIME_ONLY = int (C .SD_JOURNAL_RUNTIME_ONLY )
379
+ SD_JOURNAL_FLAG_SYSTEM = int (C .SD_JOURNAL_SYSTEM )
380
+ SD_JOURNAL_FLAG_CURRENT_USER = int (C .SD_JOURNAL_CURRENT_USER )
381
+ SD_JOURNAL_FLAG_OS_ROOT = int (C .SD_JOURNAL_OS_ROOT )
382
+ SD_JOURNAL_FLAG_ALL_NAMESPACES = int (C .SD_JOURNAL_ALL_NAMESPACES )
383
+ SD_JOURNAL_FLAG_INCLUDE_DEFAULT_NAMESPACE = int (C .SD_JOURNAL_INCLUDE_DEFAULT_NAMESPACE )
384
+ SD_JOURNAL_FLAG_TAKE_DIRECTORY_FD = int (C .SD_JOURNAL_TAKE_DIRECTORY_FD )
375
385
)
376
386
377
387
// Journal event constants
@@ -422,14 +432,20 @@ func (m *Match) String() string {
422
432
423
433
// NewJournal returns a new Journal instance pointing to the local journal
424
434
func NewJournal () (j * Journal , err error ) {
435
+ return NewJournalWithFlags (SD_JOURNAL_FLAG_LOCAL_ONLY )
436
+ }
437
+
438
+ // NewJournalWithFlags return a new Journal instance pointing to the local journal
439
+ // with a list of flags indicating the scope and type of entries that will be accessed.
440
+ func NewJournalWithFlags (flags int ) (j * Journal , err error ) {
425
441
j = & Journal {}
426
442
427
443
sd_journal_open , err := getFunction ("sd_journal_open" )
428
444
if err != nil {
429
445
return nil , err
430
446
}
431
447
432
- r := C .my_sd_journal_open (sd_journal_open , & j .cjournal , C .SD_JOURNAL_LOCAL_ONLY )
448
+ r := C .my_sd_journal_open (sd_journal_open , & j .cjournal , C .int ( flags ) )
433
449
434
450
if r < 0 {
435
451
return nil , fmt .Errorf ("failed to open journal: %s" , syscall .Errno (- r ).Error ())
0 commit comments