Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
159 lines
5.9 KiB
Go
159 lines
5.9 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package mlog
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"github.com/mattermost/logr/v2"
|
|
)
|
|
|
|
// Standard levels.
|
|
var (
|
|
LvlPanic = logr.Panic // ID = 0
|
|
LvlFatal = logr.Fatal // ID = 1
|
|
LvlError = logr.Error // ID = 2
|
|
LvlWarn = logr.Warn // ID = 3
|
|
LvlInfo = logr.Info // ID = 4
|
|
LvlDebug = logr.Debug // ID = 5
|
|
LvlTrace = logr.Trace // ID = 6
|
|
// non-standard "critical" level
|
|
LvlCritical = Level{ID: 7, Name: "critical"}
|
|
// used by redirected standard logger
|
|
LvlStdLog = Level{ID: 10, Name: "stdlog"}
|
|
// used only by the logger
|
|
LvlLogError = Level{ID: 11, Name: "logerror", Stacktrace: true}
|
|
|
|
StdAll = []Level{LvlPanic, LvlFatal, LvlError, LvlWarn, LvlInfo, LvlDebug, LvlTrace, LvlStdLog}
|
|
)
|
|
|
|
// Register custom (discrete) levels here.
|
|
// !!!!! Custom ID's must be between 20 and 32,768 !!!!!!
|
|
|
|
var (
|
|
/* Audit system */
|
|
|
|
// LvlAuditAPI is used for auditing REST API endpoint access. This is the most commonly used
|
|
// audit level and should be applied whenever a REST API endpoint is accessed. It provides
|
|
// a record of API usage patterns and access.
|
|
//
|
|
// Example usage: Logging when a user accesses the /api/v4/posts endpoint.
|
|
LvlAuditAPI = Level{ID: 100, Name: "audit-api"}
|
|
|
|
// LvlAuditContent is used for auditing content-generating operations such as creating posts,
|
|
// adding reactions, or other actions that create new content in the system. Note that this
|
|
// level can generate a large volume of logs and is typically disabled by default in production
|
|
// environments.
|
|
//
|
|
// Example usage: Logging when a user creates a new post or adds a reaction.
|
|
LvlAuditContent = Level{ID: 101, Name: "audit-content"}
|
|
|
|
// LvlAuditPerms is used for auditing permissions checks. This level is automatically applied
|
|
// when permission-related errors occur, helping to track authorization failures and access
|
|
// control issues.
|
|
//
|
|
// Example usage: Logging when a user attempts to access a resource they don't have permission for.
|
|
LvlAuditPerms = Level{ID: 102, Name: "audit-permissions"}
|
|
|
|
// LvlAuditCLI is intended for auditing command-line interface operations. This level was
|
|
// originally designed for the legacy CLI. It's mostly unused now.
|
|
LvlAuditCLI = Level{ID: 103, Name: "audit-cli"}
|
|
|
|
// LvlAuditDelivery is used for auditing the delivery of post content to users and
|
|
// integrations. This level can generate an extremely large volume of records — one per
|
|
// post per recipient — so it is deliberately not bound to the basic
|
|
// ExperimentalAuditSettings file target. An admin opts in by configuring an advanced
|
|
// audit logging target for it.
|
|
//
|
|
// Example usage: Logging that a post was included in a page of posts returned to a user.
|
|
LvlAuditDelivery = Level{ID: 104, Name: "audit-delivery"}
|
|
|
|
MLvlAuditAll = []Level{
|
|
LvlAuditAPI,
|
|
LvlAuditContent,
|
|
LvlAuditPerms,
|
|
LvlAuditCLI,
|
|
LvlAuditDelivery,
|
|
}
|
|
|
|
LvlRemoteClusterServiceDebug = Level{ID: 130, Name: "RemoteClusterServiceDebug"}
|
|
LvlRemoteClusterServiceError = Level{ID: 131, Name: "RemoteClusterServiceError"}
|
|
LvlRemoteClusterServiceWarn = Level{ID: 132, Name: "RemoteClusterServiceWarn"}
|
|
MLvlRemoteClusterServiceAll = []Level{
|
|
LvlRemoteClusterServiceDebug,
|
|
LvlRemoteClusterServiceError,
|
|
LvlRemoteClusterServiceWarn,
|
|
}
|
|
|
|
/* LDAP sync job */
|
|
|
|
LvlLDAPError = Level{ID: 140, Name: "LDAPError"}
|
|
LvlLDAPWarn = Level{ID: 141, Name: "LDAPWarn"}
|
|
LvlLDAPInfo = Level{ID: 142, Name: "LDAPInfo"}
|
|
LvlLDAPDebug = Level{ID: 143, Name: "LDAPDebug"}
|
|
LvlLDAPTrace = Level{ID: 144, Name: "LDAPTrace"}
|
|
MLvlLDAPAll = []Level{LvlLDAPError, LvlLDAPWarn, LvlLDAPInfo, LvlLDAPDebug, LvlLDAPTrace}
|
|
|
|
/* Shared Channel Sync Service */
|
|
|
|
LvlSharedChannelServiceDebug = Level{ID: 200, Name: "SharedChannelServiceDebug"}
|
|
LvlSharedChannelServiceError = Level{ID: 201, Name: "SharedChannelServiceError"}
|
|
LvlSharedChannelServiceWarn = Level{ID: 202, Name: "SharedChannelServiceWarn"}
|
|
LvlSharedChannelServiceMessagesInbound = Level{ID: 203, Name: "SharedChannelServiceMsgInbound"}
|
|
LvlSharedChannelServiceMessagesOutbound = Level{ID: 204, Name: "SharedChannelServiceMsgOutbound"}
|
|
MlvlSharedChannelServiceAll = []Level{
|
|
LvlSharedChannelServiceDebug,
|
|
LvlSharedChannelServiceError,
|
|
LvlSharedChannelServiceWarn,
|
|
LvlSharedChannelServiceMessagesInbound,
|
|
LvlSharedChannelServiceMessagesOutbound,
|
|
}
|
|
|
|
/* Notification Service */
|
|
|
|
LvlNotificationError = Level{ID: 300, Name: "NotificationError"}
|
|
LvlNotificationWarn = Level{ID: 301, Name: "NotificationWarn"}
|
|
LvlNotificationInfo = Level{ID: 302, Name: "NotificationInfo"}
|
|
LvlNotificationDebug = Level{ID: 303, Name: "NotificationDebug"}
|
|
LvlNotificationTrace = Level{ID: 304, Name: "NotificationTrace"}
|
|
MlvlNotificationAll = []Level{
|
|
LvlNotificationError,
|
|
LvlNotificationWarn,
|
|
LvlNotificationInfo,
|
|
LvlNotificationDebug,
|
|
LvlNotificationTrace,
|
|
}
|
|
)
|
|
|
|
// Combinations for LogM (log multi).
|
|
var (
|
|
MlvlRemoteClusterServiceError = []Level{LvlError, LvlRemoteClusterServiceError}
|
|
MlvlRemoteClusterServiceWarn = []Level{LvlWarn, LvlRemoteClusterServiceWarn}
|
|
|
|
MlvlSharedChannelServiceError = []Level{LvlError, LvlSharedChannelServiceError}
|
|
MlvlSharedChannelServiceWarn = []Level{LvlWarn, LvlSharedChannelServiceWarn}
|
|
|
|
MlvlLDAPError = []Level{LvlError, LvlLDAPError}
|
|
MlvlLDAPWarn = []Level{LvlWarn, LvlLDAPWarn}
|
|
MlvlLDAPInfo = []Level{LvlInfo, LvlLDAPInfo}
|
|
MlvlLDAPDebug = []Level{LvlDebug, LvlLDAPDebug}
|
|
|
|
MlvlNotificationError = []Level{LvlError, LvlNotificationError}
|
|
MlvlNotificationWarn = []Level{LvlWarn, LvlNotificationWarn}
|
|
MlvlNotificationInfo = []Level{LvlInfo, LvlNotificationInfo}
|
|
MlvlNotificationDebug = []Level{LvlDebug, LvlNotificationDebug}
|
|
MlvlNotificationTrace = []Level{LvlTrace, LvlNotificationTrace}
|
|
)
|
|
|
|
var (
|
|
// MlvlAll contains all log levels except the audit ones
|
|
MlvlAll = slices.Concat(
|
|
StdAll,
|
|
MLvlRemoteClusterServiceAll,
|
|
MLvlLDAPAll,
|
|
MlvlSharedChannelServiceAll,
|
|
MlvlNotificationAll,
|
|
)
|
|
)
|