2 * Copyright 2000-2015 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.structuralsearch.impl.matcher.predicates;
18 import com.intellij.notification.NotificationGroup;
19 import com.intellij.notification.NotificationType;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.structuralsearch.SSRBundle;
24 * @author Bas Leijdekkers
26 public class ScriptLog {
28 private final NotificationGroup myEventLog;
29 private final Project myProject;
31 public ScriptLog(Project project) {
33 myEventLog = NotificationGroup.logOnlyGroup(SSRBundle.message("structural.search.title"));
36 public void info(Object message) {
37 log(message, NotificationType.INFORMATION);
40 public void warn(Object message) {
41 log(message, NotificationType.WARNING);
44 public void error(Object message) {
45 log(message, NotificationType.ERROR);
48 private void log(Object message, NotificationType type) {
49 final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
51 for (StackTraceElement e : stackTrace) {
52 final String methodName = e.getMethodName();
53 if ("run".equals(methodName)) {
54 location = "(" + e.getFileName() + ":" + e.getLineNumber() + ") ";
58 myEventLog.createNotification(location + String.valueOf(message), type).notify(myProject);