code.gitea.io/gitea@v1.21.7/routers/private/ssh_log.go (about) 1 // Copyright 2021 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package private 5 6 import ( 7 "net/http" 8 9 "code.gitea.io/gitea/modules/context" 10 "code.gitea.io/gitea/modules/log" 11 "code.gitea.io/gitea/modules/private" 12 "code.gitea.io/gitea/modules/setting" 13 "code.gitea.io/gitea/modules/web" 14 ) 15 16 // SSHLog hook to response ssh log 17 func SSHLog(ctx *context.PrivateContext) { 18 if !setting.Log.EnableSSHLog { 19 ctx.Status(http.StatusOK) 20 return 21 } 22 23 opts := web.GetForm(ctx).(*private.SSHLogOption) 24 25 if opts.IsError { 26 log.Error("ssh: %v", opts.Message) 27 ctx.Status(http.StatusOK) 28 return 29 } 30 31 log.Debug("ssh: %v", opts.Message) 32 ctx.Status(http.StatusOK) 33 }